From 5ca769f2c5bf475f23e5a9535380e3dddfe3d2e4 Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Mon, 8 Jan 2024 14:42:57 -0800 Subject: [PATCH 01/10] fix ugly git commits to resolve conflict --- asm/README.md | 9 +- asm/asm.opam | 4 +- asm/bin/demoInterpreter.ml | 27 +++++ asm/bin/demoInterpreter.t | 157 +++++++++++++++++++++++++ asm/bin/demoParser.ml | 2 +- asm/bin/demoParser.t | 94 +++++++-------- asm/bin/dune | 12 +- asm/devbox.json | 13 +++ asm/devbox.lock | 85 ++++++++++++++ asm/dune-project | 4 +- asm/lib/ast/ast.ml | 62 +++++++--- asm/lib/interpreter/containers.ml | 24 ++++ asm/lib/interpreter/dune | 9 ++ asm/lib/interpreter/interpreter.ml | 179 +++++++++++++++++++++++++++++ asm/lib/interpreter/state.ml | 179 +++++++++++++++++++++++++++++ asm/lib/parser/operand.ml | 24 +++- asm/lib/parser/operand.mli | 6 +- asm/lib/parser/parser.ml | 10 +- asm/lib/parser/parser.mli | 3 +- asm/lib/parser/register.ml | 18 +++ asm/lib/parser/register.mli | 3 + asm/lib/parser/statement.ml | 13 ++- 22 files changed, 856 insertions(+), 81 deletions(-) create mode 100644 asm/bin/demoInterpreter.ml create mode 100644 asm/bin/demoInterpreter.t create mode 100644 asm/devbox.json create mode 100644 asm/devbox.lock create mode 100644 asm/lib/interpreter/containers.ml create mode 100644 asm/lib/interpreter/dune create mode 100644 asm/lib/interpreter/interpreter.ml create mode 100644 asm/lib/interpreter/state.ml diff --git a/asm/README.md b/asm/README.md index 5aba9b938..7d5418bd3 100644 --- a/asm/README.md +++ b/asm/README.md @@ -1,14 +1,13 @@ -### An implementaion of NASM mini-language +### An implementaion of NASM micro-language License: LGPL for implementation code + WTFPL for test examples in nasm-like language Author: Vadim Yakshigulov (vadim.iakshigulov@gmail.com) -Features done (append only): +Features done: - parser - ast +- interpreter -Features in progress (and TODOs): - -- TODO: improve parser \ No newline at end of file +Including SSE instructions and syscall diff --git a/asm/asm.opam b/asm/asm.opam index 5f31dfc9c..e1a68d135 100644 --- a/asm/asm.opam +++ b/asm/asm.opam @@ -1,8 +1,8 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.2.1" +version: "0.3.0" synopsis: "NASM assembly interpeter" -description: "Something is supported... but in december..." +description: "With some SSE instructions" maintainer: ["Vadim Yakshigulov "] authors: ["Vadim Yakshigulov "] license: "LGPL-3.0-or-later" diff --git a/asm/bin/demoInterpreter.ml b/asm/bin/demoInterpreter.ml new file mode 100644 index 000000000..d4e6cd792 --- /dev/null +++ b/asm/bin/demoInterpreter.ml @@ -0,0 +1,27 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +open Ast +open Interpreter +open State +open StateErrorMonad +open GlobalState +open Parser + +let () = + let input = Stdio.In_channel.input_all stdin in + let parsed_ast = + match parse parse_ast input with + | Result.Error e -> + Format.printf "Error: %s" e; + exit 1 + | Result.Ok x -> x + in + parse_show parse_ast show_ast input; + let eval = eval_ast parsed_ast in + let state, result = run eval initial_state in + match result with + | Result.Ok _ -> Format.printf "%s" (GlobalState.show state) + | Result.Error err -> Format.printf "%s" err +;; diff --git a/asm/bin/demoInterpreter.t b/asm/bin/demoInterpreter.t new file mode 100644 index 000000000..7043bb818 --- /dev/null +++ b/asm/bin/demoInterpreter.t @@ -0,0 +1,157 @@ + $ ./demoInterpreter.exe <<- EOF + > section .text + > global _start + > _start: + > ; Инициализируем регистры для хранения предыдущих двух чисел Фибоначчи + > mov rcx, 10 ; Ищем 10-ое число Фибоначчи + > mov rax, 0 ; F(0) + > mov rbx, 1 ; F(1) + > + > cmp rcx, 1 + > jle exit ; Если n <= 1, результат уже в rax + > sub rcx, 1 ; Первое число Фибоначчи уже в rax, начинаем с F(2) + > + > fib_loop: + > add rax, rbx ; F(n) = F(n-1) + F(n-2) + > ; Обмен значениями rax и rbx, используя xor swap trick + > xor rax, rbx + > xor rbx, rax + > xor rax, rbx + > ; Теперь rax содержит F(n-1), rbx содержит F(n) + > + > sub rcx, 1 + > cmp rcx, 0 + > jne fib_loop + > + > exit: + > ; Завершение программы и возврат значения в rax + > mov rdi, 0 ; Код возврата + > mov rax, 60 ; syscall номер для exit + > syscall + > EOF + (Directive (Section .text)) + (Directive (Global _start)) + (LabelDecl _start) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 10))))) + (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 1))))) + (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Jle (Label exit))) + (Instruction (Sub (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (LabelDecl fib_loop) + (Instruction (Add (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Xor (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Xor (Reg_64_reg_64 (Rbx, Rax)))) + (Instruction (Xor (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Sub (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 0))))) + (Instruction (Jne (Label fib_loop))) + (LabelDecl exit) + (Instruction (Mov (Reg_64_imm_a (Rdi, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) + (Instruction (Syscall (Nothing))) + Registers: + Eax: 0 + Ebp: 0 + Ebx: 0 + Ecx: 0 + Edi: 0 + Edx: 0 + Esi: 0 + Esp: 0 + Rax: 60 + Rbp: 0 + Rbx: 55 + Rcx: 0 + Rdi: 0 + Rdx: 0 + Rsi: 0 + Rsp: 0 + XMM Registers: + Xmm0: (0, 0) + Xmm1: (0, 0) + Xmm2: (0, 0) + Xmm3: (0, 0) + Xmm4: (0, 0) + Xmm5: (0, 0) + Xmm6: (0, 0) + Xmm7: (0, 0) + Stack: + Label to jump: None + Zero flag: 1 + + $ ./demoInterpreter.exe <<- EOF + > ; Считает скалярное произведение двух векторов (1, 2) и (3, 4) в xmm0 и xmm1 + > ; Результат кладет в rdx + > global redefine_start_point + > section .text + > redefine_start_point: + > mov rbx, 1 + > mov rcx, 2 + > pinsrq xmm0, rbx, 1 + > pinsrq xmm0, rcx, 0 + > mov rbx, 3 + > mov rcx, 4 + > pinsrq xmm1, rbx, 1 + > pinsrq xmm1, rcx, 0 + > + > mulpd xmm0, xmm1 + > movapd xmm2, xmm0 + > punpckhqdq xmm2, xmm2 + > addpd xmm0, xmm2 + > movq rdx, xmm0 + > exit: + > ; Завершение программы и возврат значения в rax + > mov rdi, 0 ; Код возврата + > mov rax, 60 ; syscall номер для exit + > syscall + > EOF + (Directive (Global redefine_start_point)) + (Directive (Section .text)) + (LabelDecl redefine_start_point) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 1))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 2))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm0, Rbx, (Imm_int 1))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm0, Rcx, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 3))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 4))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm1, Rbx, (Imm_int 1))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm1, Rcx, (Imm_int 0))))) + (Instruction (Mulpd (Reg_128_reg_128 (Xmm0, Xmm1)))) + (Instruction (Movapd (Reg_128_reg_128 (Xmm2, Xmm0)))) + (Instruction (Punpckhqdq (Reg_128_reg_128 (Xmm2, Xmm2)))) + (Instruction (Addpd (Reg_128_reg_128 (Xmm0, Xmm2)))) + (Instruction (Movq (Reg_64_reg_128 (Rdx, Xmm0)))) + (LabelDecl exit) + (Instruction (Mov (Reg_64_imm_a (Rdi, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) + (Instruction (Syscall (Nothing))) + Registers: + Eax: 0 + Ebp: 0 + Ebx: 0 + Ecx: 0 + Edi: 0 + Edx: 0 + Esi: 0 + Esp: 0 + Rax: 60 + Rbp: 0 + Rbx: 3 + Rcx: 4 + Rdi: 0 + Rdx: 11 + Rsi: 0 + Rsp: 0 + XMM Registers: + Xmm0: (6, 11) + Xmm1: (3, 4) + Xmm2: (3, 3) + Xmm3: (0, 0) + Xmm4: (0, 0) + Xmm5: (0, 0) + Xmm6: (0, 0) + Xmm7: (0, 0) + Stack: + Label to jump: None + Zero flag: 0 diff --git a/asm/bin/demoParser.ml b/asm/bin/demoParser.ml index ad43fbc3c..b8d7075d7 100644 --- a/asm/bin/demoParser.ml +++ b/asm/bin/demoParser.ml @@ -8,5 +8,5 @@ open Ast let () = let input = Stdio.In_channel.input_all stdin in - Parser.parse parse_ast show_ast input + parse_show parse_ast show_ast input ;; diff --git a/asm/bin/demoParser.t b/asm/bin/demoParser.t index bc59a028a..56426e1ca 100644 --- a/asm/bin/demoParser.t +++ b/asm/bin/demoParser.t @@ -1,52 +1,52 @@ $ ./demoParser.exe <<- EOF > section .text - > fibonachch: - > push rbp - > mov rbx, 0x2A - > mov rax, 0x0 - > mov rcx, 1 - > cmp rbx, 1 - > je fibonachchEnd - > cmp rbx, 2 - > je fibonachchTwo - > sub rbx, 1 - > fibonachchStart: - > sub rbx, 1 - > xor rax, rcx - > xor rcx, rax - > xor rax, rcx - > add rax, rcx - > cmp rbx, 0 - > je fibonachchEnd - > jmp fibonachchStart - > fibonachchTwo: - > mov rax, 1 - > fibonachchEnd: - > pop rbp - > ret + > global _start + > _start: + > ; Инициализируем регистры для хранения предыдущих двух чисел Фибоначчи + > mov rcx, 11 ; Ишем 10-ое число Фибоначчи + > mov rax, 0 ; F(0) + > mov rbx, 1 ; F(1) + > + > cmp rcx, 1 + > jle exit ; Если n <= 1, результат уже в rax + > sub rcx, 1 ; Первое число Фибоначчи уже в rax, начинаем с F(2) + > + > fib_loop: + > add rax, rbx ; F(n) = F(n-1) + F(n-2) + > ; Обмен значениями rax и rbx, используя xor swap trick + > xor rax, rbx + > xor rbx, rax + > xor rax, rbx + > ; Теперь rax содержит F(n-1), rbx содержит F(n) + > + > sub rcx, 1 + > cmp rcx, 1 + > jne fib_loop + > + > exit: + > ; Завершение программы и возврат значения в rax + > mov rdi, 0 ; Код возврата + > mov rax, 60 ; syscall номер для exit + > syscall > EOF (Directive (Section .text)) - (LabelDecl fibonachch) - (Instruction (Push (Reg_64 Rbp))) - (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 42))))) + (Directive (Global _start)) + (LabelDecl _start) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 11))))) (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 0))))) - (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 1))))) - (Instruction (Cmp (Reg_64_imm_a (Rbx, (Imm_int 1))))) - (Instruction (Je (Label (Label_ref fibonachchEnd)))) - (Instruction (Cmp (Reg_64_imm_a (Rbx, (Imm_int 2))))) - (Instruction (Je (Label (Label_ref fibonachchTwo)))) - (Instruction (Sub (Reg_64_imm_a (Rbx, (Imm_int 1))))) - (LabelDecl fibonachchStart) - (Instruction (Sub (Reg_64_imm_a (Rbx, (Imm_int 1))))) - (Instruction (Xor (Reg_64_reg_64 (Rax, Rcx)))) - (Instruction (Xor (Reg_64_reg_64 (Rcx, Rax)))) - (Instruction (Xor (Reg_64_reg_64 (Rax, Rcx)))) - (Instruction (Add (Reg_64_reg_64 (Rax, Rcx)))) - (Instruction (Cmp (Reg_64_imm_a (Rbx, (Imm_int 0))))) - (Instruction (Je (Label (Label_ref fibonachchEnd)))) - (Instruction (Jmp (Label (Label_ref fibonachchStart)))) - (LabelDecl fibonachchTwo) - (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 1))))) - (LabelDecl fibonachchEnd) - (Instruction (Pop (Reg_64 Rbp))) - (Instruction (Ret (Nothing))) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 1))))) + (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Jle (Label exit))) + (Instruction (Sub (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (LabelDecl fib_loop) + (Instruction (Add (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Xor (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Xor (Reg_64_reg_64 (Rbx, Rax)))) + (Instruction (Xor (Reg_64_reg_64 (Rax, Rbx)))) + (Instruction (Sub (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Jne (Label fib_loop))) + (LabelDecl exit) + (Instruction (Mov (Reg_64_imm_a (Rdi, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) + (Instruction (Syscall (Nothing))) diff --git a/asm/bin/dune b/asm/bin/dune index 5d7172057..a8bd7141d 100644 --- a/asm/bin/dune +++ b/asm/bin/dune @@ -1,10 +1,18 @@ (executable (name demoParser) (modules demoParser) - (public_name asm.demos) + (public_name asm.demoParser) (libraries asm.Parser stdio) (instrumentation (backend bisect_ppx))) +(executable + (name demoInterpreter) + (modules demoInterpreter) + (public_name asm.demoInterpreter) + (libraries asm.Parser asm.Interpreter stdio) + (instrumentation + (backend bisect_ppx))) + (cram - (deps ./demoParser.exe)) + (deps ./demoParser.exe ./demoInterpreter.exe)) diff --git a/asm/devbox.json b/asm/devbox.json new file mode 100644 index 000000000..cd38ddcca --- /dev/null +++ b/asm/devbox.json @@ -0,0 +1,13 @@ +{ + "packages": [ + "ocaml@latest", + "opam@latest", + "opam-installer@latest", + "nasm@latest" + ], + "shell": { + "init_hook": [ + "eval $(opam env)" + ] + } +} diff --git a/asm/devbox.lock b/asm/devbox.lock new file mode 100644 index 000000000..1d6d91e13 --- /dev/null +++ b/asm/devbox.lock @@ -0,0 +1,85 @@ +{ + "lockfile_version": "1", + "packages": { + "nasm@latest": { + "last_modified": "2023-12-13T22:54:10Z", + "resolved": "github:NixOS/nixpkgs/fd04bea4cbf76f86f244b9e2549fca066db8ddff#nasm", + "source": "devbox-search", + "version": "2.16.01", + "systems": { + "aarch64-darwin": { + "store_path": "/nix/store/sfzqh8x57z61qhmlflidxjnqy73dc46a-nasm-2.16.01" + }, + "aarch64-linux": { + "store_path": "/nix/store/l6a3rh9bpnhaipyjma5d7zscy6192rq4-nasm-2.16.01" + }, + "x86_64-darwin": { + "store_path": "/nix/store/5mphhd0gk5mphzflrl491wil3hi08nw8-nasm-2.16.01" + }, + "x86_64-linux": { + "store_path": "/nix/store/nmlxrc78byf1kddnj5pam34r74sa01mw-nasm-2.16.01" + } + } + }, + "ocaml@latest": { + "last_modified": "2023-11-17T14:14:56Z", + "resolved": "github:NixOS/nixpkgs/a71323f68d4377d12c04a5410e214495ec598d4c#ocaml", + "source": "devbox-search", + "version": "4.14.1", + "systems": { + "aarch64-darwin": { + "store_path": "/nix/store/mgrm4ava1sp8ascl29fa2jfyx1wvh0c9-ocaml-4.14.1" + }, + "aarch64-linux": { + "store_path": "/nix/store/k4hc9lxwy9lg3ijbaq8rj6zfvss01pdr-ocaml-4.14.1" + }, + "x86_64-darwin": { + "store_path": "/nix/store/f9v69kbkixyvv1wg442cm6fh1b6pw5yd-ocaml-4.14.1" + }, + "x86_64-linux": { + "store_path": "/nix/store/dpk6p6z5zwl1jfn7hwkgyfwaj7zdpg77-ocaml-4.14.1" + } + } + }, + "opam-installer@latest": { + "last_modified": "2023-11-30T09:21:56Z", + "resolved": "github:NixOS/nixpkgs/f5c27c6136db4d76c30e533c20517df6864c46ee#opam-installer", + "source": "devbox-search", + "version": "2.1.5", + "systems": { + "aarch64-darwin": { + "store_path": "/nix/store/k68jhbkhxqhj6wblc4n1nqpkin767gdh-ocaml4.14.1-opam-installer-2.1.5" + }, + "aarch64-linux": { + "store_path": "/nix/store/zfcvqlkshnv8xlmfb5sgwa45p9yplpml-ocaml4.14.1-opam-installer-2.1.5" + }, + "x86_64-darwin": { + "store_path": "/nix/store/blrl8k37dggxdyaz14m22g49ffq1jag7-ocaml4.14.1-opam-installer-2.1.5" + }, + "x86_64-linux": { + "store_path": "/nix/store/d6kz2x939ir29kc7q3vb18wb4d6sqr1s-ocaml4.14.1-opam-installer-2.1.5" + } + } + }, + "opam@latest": { + "last_modified": "2023-11-17T14:14:56Z", + "resolved": "github:NixOS/nixpkgs/a71323f68d4377d12c04a5410e214495ec598d4c#opam", + "source": "devbox-search", + "version": "2.1.5", + "systems": { + "aarch64-darwin": { + "store_path": "/nix/store/2nwag1grkd3xbchx9qgz4sb1ln2jmj2w-opam-2.1.5" + }, + "aarch64-linux": { + "store_path": "/nix/store/rhkz6cmbqvzv92xpv777ab4s2bjf3975-opam-2.1.5" + }, + "x86_64-darwin": { + "store_path": "/nix/store/yi32z2pzvjypc60mpv9f4xp9irnph982-opam-2.1.5" + }, + "x86_64-linux": { + "store_path": "/nix/store/sbdpaiz5l0nsv3hbl2gln73r42rggcj5-opam-2.1.5" + } + } + } + } +} diff --git a/asm/dune-project b/asm/dune-project index 2ae1710dc..826a813e2 100644 --- a/asm/dune-project +++ b/asm/dune-project @@ -15,8 +15,8 @@ (package (name asm) (synopsis "NASM assembly interpeter") - (description "Something is supported... but in december...") - (version 0.2.1) + (description "With some SSE instructions") + (version 0.3.0) (depends dune angstrom diff --git a/asm/lib/ast/ast.ml b/asm/lib/ast/ast.ml index 484508a02..55d6a247f 100644 --- a/asm/lib/ast/ast.ml +++ b/asm/lib/ast/ast.ml @@ -4,6 +4,7 @@ type i32 type i64 +type i128 type _ register = | Eax : i32 register @@ -22,11 +23,18 @@ type _ register = | Rbp : i64 register | Rsi : i64 register | Rdi : i64 register + | Xmm0 : i128 register + | Xmm1 : i128 register + | Xmm2 : i128 register + | Xmm3 : i128 register + | Xmm4 : i128 register + | Xmm5 : i128 register + | Xmm6 : i128 register + | Xmm7 : i128 register [@@deriving variants] type _ immediate = Imm_int of int [@@deriving variants] type 'a register_ref = Register_ref of 'a register [@@deriving variants] -type label_ref = Label_ref of string [@@deriving variants] type _ operand = | Reg_32_reg_32 : i32 register * i32 register -> [> `Reg_32_reg_32 ] operand @@ -44,13 +52,19 @@ type _ operand = | Mem_32 : i32 register_ref -> [> `Mem_32 ] operand | Mem_64 : i64 register_ref -> [> `Mem_64 ] operand (** Single memory operand*) | Nothing : [> `Nothing ] operand (** Mnemonic without operand (e.g Ret)*) - | Label : label_ref -> [> `Label ] operand (** Label operand (e.g Jmp lbl) *) + | Label : string -> [> `Label ] operand (** Label operand (e.g Jmp lbl) *) + | Reg_128 : i128 register -> [> `Reg_128 ] operand + | Reg_64_reg_128 : i64 register * i128 register -> [> `Reg_64_reg_128 ] operand + | Reg_128_reg_64 : i128 register * i64 register -> [> `Reg_128_reg_64 ] operand + | Reg_128_reg_128 : i128 register * i128 register -> [> `Reg_128_reg_128 ] operand + | Reg_128_reg_64_imm_a : + i128 register * i64 register * 'a immediate + -> [> `Reg_128_reg_64_imm_a ] operand [@@deriving variants] -(** Some mnemonic variants are not supported, but it's easy to add them later *) +(** Some (actually most of them) mnemonic variants are not supported, but it's easy to add them later *) type _ mnemonic = | Mov : [< `Reg_64_imm_a ] mnemonic - | Ret : [< `Nothing ] mnemonic | Push : [< `Reg_64 ] mnemonic | Add : [< `Reg_64_reg_64 ] mnemonic | Xor : [< `Reg_64_reg_64 ] mnemonic @@ -60,6 +74,16 @@ type _ mnemonic = | Sub : [< `Reg_64_imm_a ] mnemonic | Cmp : [< `Reg_64_imm_a ] mnemonic | Je : [< `Label ] mnemonic + | Jne : [< `Label ] mnemonic + | Jle : [< `Label ] mnemonic + | Movq : [< `Reg_64_reg_128 | `Reg_128_reg_64 ] mnemonic + | Punpckhqdq : [< `Reg_128_reg_128 ] mnemonic + | Movapd : [< `Reg_128_reg_128 ] mnemonic + (** Real instruction name, not the cat jumped on the keyboard *) + | Pinsrq : [< `Reg_128_reg_64_imm_a ] mnemonic + | Addpd : [< `Reg_128_reg_128 ] mnemonic + | Mulpd : [< `Reg_128_reg_128 ] mnemonic + (** Not sure that these instructions can really be used with integer values in xmm registers. The specification of the instructions is a complete mess*) [@@deriving variants] type directive = @@ -86,20 +110,19 @@ let show_register_ref = function | Register_ref x -> Printf.sprintf {|(Register_ref %s)|} (show_register x) ;; -let show_label_ref = function - | Label_ref x -> Printf.sprintf {|(Label_ref %s)|} x -;; - let show_directive = function | Section x -> Printf.sprintf {|(Section %s)|} x | Global x -> Printf.sprintf {|(Global %s)|} x ;; -type show_operand_wrapper = W : 'kind_of operand -> show_operand_wrapper +type args_wrapper = Wargs : 'kind_of operand -> args_wrapper [@@deriving variants] -let show_operand (W op) = +type register_wrapper = Wregister : 'a register -> register_wrapper +[@@deriving variants] + +let show_operand (Wargs op) = match op with - | Reg_32 x -> Printf.sprintf {|(Reg_32 %s)|} (show_register x) + | Reg_32 x -> Printf.sprintf {|(Rezg_32 %s)|} (show_register x) | Reg_64 x -> Printf.sprintf {|(Reg_64 %s)|} (show_register x) | Mem_32 x -> Printf.sprintf {|(Mem_32 %s)|} (show_register_ref x) | Mem_64 x -> Printf.sprintf {|(Mem_64 %s)|} (show_register_ref x) @@ -118,12 +141,25 @@ let show_operand (W op) = | Reg_64_reg_64 (x, y) -> Printf.sprintf {|(Reg_64_reg_64 (%s, %s))|} (show_register x) (show_register y) | Imm_a x -> Printf.sprintf {|(Imm_a %s)|} (show_immediate x) - | Label x -> Printf.sprintf {|(Label %s)|} (show_label_ref x) + | Label x -> Printf.sprintf {|(Label %s)|} x | Nothing -> "(Nothing)" | Reg_32_imm_a (x, y) -> Printf.sprintf {|(Reg_32_imm_a (%s, %s))|} (show_register x) (show_immediate y) | Reg_64_imm_a (x, y) -> Printf.sprintf {|(Reg_64_imm_a (%s, %s))|} (show_register x) (show_immediate y) + | Reg_128_reg_64 (x, y) -> + Printf.sprintf {|(Reg_128_reg_64 (%s, %s))|} (show_register x) (show_register y) + | Reg_128_reg_128 (x, y) -> + Printf.sprintf {|(Reg_128_reg_128 (%s, %s))|} (show_register x) (show_register y) + | Reg_64_reg_128 (x, y) -> + Printf.sprintf {|(Reg_64_reg_128 (%s, %s))|} (show_register x) (show_register y) + | Reg_128 x -> Printf.sprintf {|(Reg_128 %s)|} (show_register x) + | Reg_128_reg_64_imm_a (x, y, z) -> + Printf.sprintf + {|(Reg_128_reg_64_imm_a (%s, %s, %s))|} + (show_register x) + (show_register y) + (show_immediate z) ;; let show_statement = function @@ -133,7 +169,7 @@ let show_statement = function Printf.sprintf {|(Instruction (%s %s))|} (show_mnemonic mnemonic) - (show_operand (W args)) + (show_operand (Wargs args)) ;; let show_ast ast = String.concat "\n" (List.map show_statement ast) diff --git a/asm/lib/interpreter/containers.ml b/asm/lib/interpreter/containers.ml new file mode 100644 index 000000000..8c3827e04 --- /dev/null +++ b/asm/lib/interpreter/containers.ml @@ -0,0 +1,24 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +open Ast +module StringMap = Map.Make (String) +module IntMap = Map.Make (Int) + +module ListStack = struct + type 'a t = 'a list + + let empty = [] + let push x s = x :: s + + let peek = function + | [] -> None + | h :: _ -> Some h + ;; + + let pop = function + | [] -> None + | _ :: tl -> Some tl + ;; +end diff --git a/asm/lib/interpreter/dune b/asm/lib/interpreter/dune new file mode 100644 index 000000000..41530eef8 --- /dev/null +++ b/asm/lib/interpreter/dune @@ -0,0 +1,9 @@ +(library + (name interpreter) + (public_name asm.Interpreter) + (libraries base angstrom ast parser) + (instrumentation + (backend bisect_ppx)) + (preprocess + (pps ppx_expect ppx_inline_test)) + (inline_tests)) diff --git a/asm/lib/interpreter/interpreter.ml b/asm/lib/interpreter/interpreter.ml new file mode 100644 index 000000000..9c76b8692 --- /dev/null +++ b/asm/lib/interpreter/interpreter.ml @@ -0,0 +1,179 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +open State +open Ast +open StateErrorMonad +open GlobalState + +let ignore = return () + +let eval_syscall = + let* rax = read_reg rax in + let* rdi = read_reg rdi in + let* rsi = read_reg rsi in + let* rdx = read_reg rdx in + match rax, rdi, rsi, rdx with + | 60, errcode, _, _ -> write_exit_code errcode + | _ -> fail "Unsupported syscall" +;; + +let eval_directive = function + | Section _ -> ignore + | Global label -> write_label_to_jmp label +;; + +let eval_statement = function + | Instruction (Mov, args) -> + (match args with + | Reg_64_imm_a (r, Imm_int i) -> write_reg r i) + | Instruction (Push, args) -> + (match args with + | Reg_64 r -> + let* v = read_reg r in + push_reg v) + | Instruction (Add, args) -> + (match args with + | Reg_64_reg_64 (r1, r2) -> + let* v1 = read_reg r1 in + let* v2 = read_reg r2 in + write_reg r1 (v1 + v2)) + | Instruction (Xor, args) -> + (match args with + | Reg_64_reg_64 (r1, r2) -> + let* v1 = read_reg r1 in + let* v2 = read_reg r2 in + write_reg r1 (v1 lxor v2)) + | Instruction (Syscall, _) -> eval_syscall + | Instruction (Pop, args) -> + (match args with + | Reg_64 r -> pop_to_reg r) + | Instruction (Jmp, Label label) -> write_label_to_jmp label + | Instruction (Sub, args) -> + (match args with + | Reg_64_imm_a (r, Imm_int i) -> + let* v = read_reg r in + write_reg r (v - i)) + | Instruction (Cmp, args) -> + (match args with + | Reg_64_imm_a (r, Imm_int i) -> + let* v = read_reg r in + let zero_flag = if v = i then 1 else 0 in + let* _ = write_zero_flag zero_flag in + let carry_flag = if v < i then 1 else 0 in + write_carry_flag carry_flag) + | Instruction (Je, Label label) -> + let* zero_flag = read_zero_flag in + if zero_flag = 1 then write_label_to_jmp label else ignore + | Instruction (Jle, Label label) -> + let* zero_flag = read_zero_flag in + let* carry_flag = read_carry_flag in + (match zero_flag, carry_flag with + | 1, 1 | 0, 1 | 1, 0 -> write_label_to_jmp label + | _, _ -> ignore) + | Instruction (Jne, Label label) -> + let* zero_flag = read_zero_flag in + if zero_flag = 0 then write_label_to_jmp label else ignore + | Instruction (Movq, args) -> + (match args with + | Reg_64_reg_128 (r1, r2) -> + let* _high, low = read_xmm_reg r2 in + write_reg r1 low + | Reg_128_reg_64 (r1, r2) -> + let* v2 = read_reg r2 in + write_xmm_reg r1 (0, v2)) + | Instruction (Punpckhqdq, args) -> + (match args with + | Reg_128_reg_128 (r1, r2) -> + let* high1, _low1 = read_xmm_reg r1 in + let* high2, _low2 = read_xmm_reg r2 in + write_xmm_reg r1 (high1, high2)) + | Instruction (Addpd, args) -> + (match args with + | Reg_128_reg_128 (r1, r2) -> + let* high1, low1 = read_xmm_reg r1 in + let* high2, low2 = read_xmm_reg r2 in + write_xmm_reg r1 (high1 + high2, low1 + low2)) + | Instruction (Mulpd, args) -> + (match args with + | Reg_128_reg_128 (r1, r2) -> + let* high1, low1 = read_xmm_reg r1 in + let* high2, low2 = read_xmm_reg r2 in + write_xmm_reg r1 (high1 * high2, low1 * low2)) + | Instruction (Pinsrq, args) -> + (match args with + | Reg_128_reg_64_imm_a (r1, r2, Imm_int 0) -> + let* high, _low = read_xmm_reg r1 in + let* v2 = read_reg r2 in + write_xmm_reg r1 (high, v2) + | Reg_128_reg_64_imm_a (r1, r2, Imm_int 1) -> + let* _high, low = read_xmm_reg r1 in + let* v2 = read_reg r2 in + write_xmm_reg r1 (v2, low) + | _ -> fail "Undefined instruction") + | Instruction (Movapd, args) -> + (match args with + | Reg_128_reg_128 (r1, r2) -> + let* high1, low1 = read_xmm_reg r2 in + write_xmm_reg r1 (high1, low1)) + | Directive _ -> ignore + | Label_decl _ -> ignore +;; + +let find_and_set_starting_label ast = + let label_from_global = + List.find_map + (function + | Directive (Global label) -> Some label + | _ -> None) + ast + in + GlobalState.update (fun state -> return { state with label_to_jmp = label_from_global }) +;; + +let get_next_statement_index ast current_index = + let handle_label_jump label = + match List.find_index (fun x -> x = Label_decl label) ast with + | Some index -> + let* _ = reset_label_to_jmp in + return (index + 1) + | None -> fail "Can't jump to undefined label" + in + let* state = read in + match state.label_to_jmp with + | Some label_to_jmp -> handle_label_jump label_to_jmp + | None -> return (current_index + 1) +;; + +let eval_ast ast = + let* _ = find_and_set_starting_label ast in + (* Determines if the program should exit based on the exit code. *) + let should_exit_program = + let* state = read in + match state.exit_code with + | Some _ -> return true + | None -> return false + in + (* Checks if there is no more statements to execute. *) + let no_statement_to_execute index = index >= List.length ast in + (* Handles the situation when there are no more statements to execute. *) + let handle_end_of_input index = + if no_statement_to_execute index then write_exit_code 0 else ignore + in + (* Recursively executes statements starting from the given index. *) + let rec execute_statements current_index = + let* next_statement_index = get_next_statement_index ast current_index in + let* _ = handle_end_of_input next_statement_index in + let* should_exit = should_exit_program in + if should_exit + then return () + else ( + let statement = List.nth ast next_statement_index in + let* _ = eval_statement statement in + execute_statements next_statement_index) + in + execute_statements (-1) +;; + +module State = State diff --git a/asm/lib/interpreter/state.ml b/asm/lib/interpreter/state.ml new file mode 100644 index 000000000..4fed987d1 --- /dev/null +++ b/asm/lib/interpreter/state.ml @@ -0,0 +1,179 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +open Containers +open Ast + +module StateErrorMonad = struct + type ('st, 'a) t = 'st -> 'st * ('a, string) Result.t + + let return x : _ = fun st -> st, Result.ok x + let fail err st = st, Result.error err + + let ( >>= ) : 's 'a 'b. ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t = + fun x f : _ -> + fun st -> + let st, x = x st in + match x with + | Result.Ok x -> f x st + | Result.Error s -> st, Result.Error s + ;; + + let read : ('st, 'st) t = fun st -> st, Result.Ok st + let write : 'st -> ('st, unit) t = fun st _old_state -> st, Result.Ok () + let run : ('st, 'a) t -> 'st -> 'st * ('a, string) Result.t = fun f st -> f st + let ( let* ) = ( >>= ) +end + +open StateErrorMonad + +module GlobalState = struct + type t = + { registers : int StringMap.t + ; xmm_registers : (int * int) StringMap.t + ; stack : int ListStack.t + ; label_to_jmp : string option + ; zero_flag : int + ; carry_flag : int + ; exit_code : int option + } + + let initialize_registers_with filter_fn value = + Variants_of_register.descriptions + |> List.filter (fun (name, _) -> filter_fn name) + |> List.map (fun (name, _) -> name, value) + |> StringMap.of_list + ;; + + let initialize_registers = + initialize_registers_with (fun name -> not (String.starts_with ~prefix:"Xmm" name)) 0 + ;; + + let initialize_xmm_registers = + initialize_registers_with (fun name -> String.starts_with ~prefix:"Xmm" name) (0, 0) + ;; + + let initial_state = + { registers = initialize_registers + ; xmm_registers = initialize_xmm_registers + ; stack = ListStack.empty + ; label_to_jmp = None + ; zero_flag = 0 + ; carry_flag = 0 + ; exit_code = None + } + ;; + + let update updater = + let* state = read in + let* new_state = updater state in + write new_state + ;; + + let show state = + let show_map title show_value map = + let show_item (key, value) = Printf.sprintf "%s: %s" key (show_value value) in + Printf.sprintf + "%s:\n%s" + title + (List.map show_item (StringMap.bindings map) |> String.concat "\n") + in + let show_list title format_item list = + Printf.sprintf "%s: %s" title (List.map format_item list |> String.concat ", ") + in + let show_registers = show_map "Registers" string_of_int state.registers in + let show_xmm_registers = + show_map + "XMM Registers" + (fun (a, b) -> Printf.sprintf "(%d, %d)" a b) + state.xmm_registers + in + let show_stack = show_list "Stack" string_of_int state.stack in + let show_label_to_jump = + Printf.sprintf "Label to jump: %s" (Option.value ~default:"None" state.label_to_jmp) + in + let show_zero_flag = Printf.sprintf "Zero flag: %d" state.zero_flag in + [ show_registers; show_xmm_registers; show_stack; show_label_to_jump; show_zero_flag ] + |> String.concat "\n" + ;; +end + +open GlobalState + +(** Readers *) +let read_label_to_jmp = + let* state = read in + return state.label_to_jmp +;; + +let read_zero_flag = + let* state = read in + return state.zero_flag +;; + +let read_carry_flag = + let* state = read in + return state.carry_flag +;; + +let peek_reg = + let* state = read in + return (ListStack.peek state.stack) +;; + +let read_generic_reg reg get_registers = + let key = Variants_of_register.to_name reg in + let* state = read in + match StringMap.find_opt key (get_registers state) with + | Some x -> return x + | None -> fail "Reading from uninitialized register" +;; + +let read_reg reg = read_generic_reg reg (fun state -> state.registers) +let read_xmm_reg reg = read_generic_reg reg (fun state -> state.xmm_registers) + +(** Writers *) +let write_reg reg value = + let key = Variants_of_register.to_name reg in + update (fun state -> + return { state with registers = StringMap.add key value state.registers }) +;; + +let write_xmm_reg reg value = + let key = Variants_of_register.to_name reg in + update (fun state -> + return { state with xmm_registers = StringMap.add key value state.xmm_registers }) +;; + +let push_reg reg = + update (fun state -> return { state with stack = ListStack.push reg state.stack }) +;; + +let pop_to_reg reg = + let pop state = + match ListStack.pop state.stack with + | Some x -> return { state with stack = x } + | None -> fail "Pop from empty stack is prohibited" + in + let* top = peek_reg in + match top with + | Some v -> + let* _ = update pop in + write_reg reg v + | None -> fail "Pop from empty stack is prohibited" +;; + +let reset_label_to_jmp = update (fun state -> return { state with label_to_jmp = None }) + +let write_label_to_jmp label = + update (fun state -> return { state with label_to_jmp = Some label }) +;; + +let write_zero_flag value = update (fun state -> return { state with zero_flag = value }) + +let write_carry_flag value = + update (fun state -> return { state with carry_flag = value }) +;; + +let write_exit_code code = update (fun state -> return { state with exit_code = Some code }) \ No newline at end of file diff --git a/asm/lib/parser/operand.ml b/asm/lib/parser/operand.ml index 558a9baf7..265ddac3b 100644 --- a/asm/lib/parser/operand.ml +++ b/asm/lib/parser/operand.ml @@ -8,9 +8,9 @@ open Common open Register open Immediate -let parse_lable_ref = label_ref <$> label_name let parse_reg_32 = reg_32 <$> parse_32_register let parse_reg_64 = reg_64 <$> parse_64_register +let parse_reg_128 = reg_128 <$> parse_128_register let parse_imm_a = imm_a <$> parse_immidiate let parse_mem_32_mem_32 = @@ -31,7 +31,27 @@ let parse_reg_64_reg_64 = let parse_mem_32 = mem_32 <$> parse_32_register_ref let parse_mem_64 = mem_64 <$> parse_64_register_ref -let parse_label_operand = label <$> parse_lable_ref +let parse_label_operand = label <$> label_name let parse_nothing = return nothing let parse_reg_32_imm_a = lift2 reg_32_imm_a parse_32_register (comma *> parse_immidiate) let parse_reg_64_imm_a = lift2 reg_64_imm_a parse_64_register (comma *> parse_immidiate) + +let parse_reg_128_reg_128 = + lift2 reg_128_reg_128 parse_128_register (comma *> parse_128_register) +;; + +let parse_reg_128_reg_64 = + lift2 reg_128_reg_64 parse_128_register (comma *> parse_64_register) +;; + +let parse_reg_64_reg_128 = + lift2 reg_64_reg_128 parse_64_register (comma *> parse_128_register) +;; + +let parse_reg_128_reg_64_imm_a = + lift3 + reg_128_reg_64_imm_a + parse_128_register + (comma *> parse_64_register) + (comma *> parse_immidiate) +;; diff --git a/asm/lib/parser/operand.mli b/asm/lib/parser/operand.mli index ac3f8a133..9ab745725 100644 --- a/asm/lib/parser/operand.mli +++ b/asm/lib/parser/operand.mli @@ -2,9 +2,9 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -val parse_lable_ref : Ast.label_ref Angstrom.t val parse_reg_32 : [ `Reg_32 ] Ast.operand Angstrom.t val parse_reg_64 : [ `Reg_64 ] Ast.operand Angstrom.t +val parse_reg_128 : [ `Reg_128 ] Ast.operand Angstrom.t val parse_imm_a : [ `Imm_a ] Ast.operand Angstrom.t val parse_mem_32_mem_32 : [ `Mem_32_mem_32 ] Ast.operand Angstrom.t val parse_mem_64_mem_64 : [ `Mem_64_mem_64 ] Ast.operand Angstrom.t @@ -16,3 +16,7 @@ val parse_label_operand : [ `Label ] Ast.operand Angstrom.t val parse_nothing : [ `Nothing ] Ast.operand Angstrom.t val parse_reg_32_imm_a : [ `Reg_32_imm_a ] Ast.operand Angstrom.t val parse_reg_64_imm_a : [ `Reg_64_imm_a ] Ast.operand Angstrom.t +val parse_reg_128_reg_128 : [ `Reg_128_reg_128 ] Ast.operand Angstrom.t +val parse_reg_128_reg_64 : [ `Reg_128_reg_64 ] Ast.operand Angstrom.t +val parse_reg_64_reg_128 : [ `Reg_64_reg_128 ] Ast.operand Angstrom.t +val parse_reg_128_reg_64_imm_a : [ `Reg_128_reg_64_imm_a ] Ast.operand Angstrom.t diff --git a/asm/lib/parser/parser.ml b/asm/lib/parser/parser.ml index 831f349e0..f9afc97a1 100644 --- a/asm/lib/parser/parser.ml +++ b/asm/lib/parser/parser.ml @@ -13,8 +13,10 @@ let parse_ast = <* skip_empty_lines ;; -let parse parser show str = - match Angstrom.parse_string ~consume:Consume.Prefix parser str with +let parse parser str = Angstrom.parse_string ~consume:Consume.Prefix parser str + +let parse_show parser show str = + match parse parser str with | Result.Error e -> Format.printf "Error: %s" e - | Result.Ok ast -> Format.printf "%s" (show ast) -;; + | Result.Ok ast -> Format.printf "%s\n" (show ast) +;; \ No newline at end of file diff --git a/asm/lib/parser/parser.mli b/asm/lib/parser/parser.mli index 560e27a20..ac72360bc 100644 --- a/asm/lib/parser/parser.mli +++ b/asm/lib/parser/parser.mli @@ -3,4 +3,5 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) val parse_ast : Ast.statement list Angstrom.t -val parse : 'a Angstrom.t -> ('a -> string) -> string -> unit +val parse : 'a Angstrom.t -> string -> ('a, string) result +val parse_show : 'a Angstrom.t -> ('a -> string) -> string -> unit diff --git a/asm/lib/parser/register.ml b/asm/lib/parser/register.ml index d3a334ed8..8d09579e6 100644 --- a/asm/lib/parser/register.ml +++ b/asm/lib/parser/register.ml @@ -34,6 +34,20 @@ let parse_64_register = ] ;; +let parse_128_register = + choice + ~failure_msg:"parse_128_register" + [ string_ci "xmm0" *> return xmm0 + ; string_ci "xmm1" *> return xmm1 + ; string_ci "xmm2" *> return xmm2 + ; string_ci "xmm3" *> return xmm3 + ; string_ci "xmm4" *> return xmm4 + ; string_ci "xmm5" *> return xmm5 + ; string_ci "xmm6" *> return xmm6 + ; string_ci "xmm7" *> return xmm7 + ] +;; + let between_brackets parser = between (char '[') (char ']') parser "between_brackets" let parse_32_register_ref = @@ -43,3 +57,7 @@ let parse_32_register_ref = let parse_64_register_ref = between_brackets parse_64_register >>| register_ref "parse_64_register_ref" ;; + +let parse_128_register_ref = + between_brackets parse_128_register >>| register_ref "parse_128_register_ref" +;; diff --git a/asm/lib/parser/register.mli b/asm/lib/parser/register.mli index 38f4880c1..3d6b213da 100644 --- a/asm/lib/parser/register.mli +++ b/asm/lib/parser/register.mli @@ -4,5 +4,8 @@ val parse_32_register : Ast.i32 Ast.register Angstrom.t val parse_64_register : Ast.i64 Ast.register Angstrom.t +val parse_128_register : Ast.i128 Ast.register Angstrom.t +val between_brackets : 'a Angstrom.t -> 'a Angstrom.t val parse_32_register_ref : Ast.i32 Ast.register_ref Angstrom.t val parse_64_register_ref : Ast.i64 Ast.register_ref Angstrom.t +val parse_128_register_ref : Ast.i128 Ast.register_ref Angstrom.t diff --git a/asm/lib/parser/statement.ml b/asm/lib/parser/statement.ml index 8d5369343..dc1a822c9 100644 --- a/asm/lib/parser/statement.ml +++ b/asm/lib/parser/statement.ml @@ -18,7 +18,6 @@ let parse_instruction = in choice [ gen_instruction "mov" [ instruction mov <$> parse_reg_64_imm_a ] - ; gen_instruction "ret" [ instruction ret <$> parse_nothing ] ; gen_instruction "push" [ instruction push <$> parse_reg_64 ] ; gen_instruction "add" [ instruction add <$> parse_reg_64_reg_64 ] ; gen_instruction "xor" [ instruction xor <$> parse_reg_64_reg_64 ] @@ -27,7 +26,19 @@ let parse_instruction = ; gen_instruction "jmp" [ instruction jmp <$> parse_label_operand ] ; gen_instruction "sub" [ instruction sub <$> parse_reg_64_imm_a ] ; gen_instruction "cmp" [ instruction cmp <$> parse_reg_64_imm_a ] + ; gen_instruction "jle" [ instruction jle <$> parse_label_operand ] + ; gen_instruction "jne" [ instruction jne <$> parse_label_operand ] ; gen_instruction "je" [ instruction je <$> parse_label_operand ] + ; gen_instruction + "movq" + [ instruction movq <$> parse_reg_128_reg_64 + ; instruction movq <$> parse_reg_64_reg_128 + ] + ; gen_instruction "movapd" [ instruction movapd <$> parse_reg_128_reg_128 ] + ; gen_instruction "punpckhqdq" [ instruction punpckhqdq <$> parse_reg_128_reg_128 ] + ; gen_instruction "addpd" [ instruction addpd <$> parse_reg_128_reg_128 ] + ; gen_instruction "pinsrq" [instruction pinsrq <$> parse_reg_128_reg_64_imm_a] + ; gen_instruction "mulpd" [ instruction mulpd <$> parse_reg_128_reg_128 ] ] ;; From 3b1229d70610ef2b25a22739db5efb33aedbb8af Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Sun, 31 Dec 2023 18:32:32 +0300 Subject: [PATCH 02/10] fix: replace unsupported function --- asm/lib/interpreter/state.ml | 7 +++++-- asm/lib/parser/statement.ml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/asm/lib/interpreter/state.ml b/asm/lib/interpreter/state.ml index 4fed987d1..77718f9ed 100644 --- a/asm/lib/interpreter/state.ml +++ b/asm/lib/interpreter/state.ml @@ -40,10 +40,11 @@ module GlobalState = struct } let initialize_registers_with filter_fn value = + let add_to_map map (key, value) = StringMap.add key value map in Variants_of_register.descriptions |> List.filter (fun (name, _) -> filter_fn name) |> List.map (fun (name, _) -> name, value) - |> StringMap.of_list + |> List.fold_left add_to_map StringMap.empty ;; let initialize_registers = @@ -176,4 +177,6 @@ let write_carry_flag value = update (fun state -> return { state with carry_flag = value }) ;; -let write_exit_code code = update (fun state -> return { state with exit_code = Some code }) \ No newline at end of file +let write_exit_code code = + update (fun state -> return { state with exit_code = Some code }) +;; diff --git a/asm/lib/parser/statement.ml b/asm/lib/parser/statement.ml index dc1a822c9..e3889518d 100644 --- a/asm/lib/parser/statement.ml +++ b/asm/lib/parser/statement.ml @@ -37,7 +37,7 @@ let parse_instruction = ; gen_instruction "movapd" [ instruction movapd <$> parse_reg_128_reg_128 ] ; gen_instruction "punpckhqdq" [ instruction punpckhqdq <$> parse_reg_128_reg_128 ] ; gen_instruction "addpd" [ instruction addpd <$> parse_reg_128_reg_128 ] - ; gen_instruction "pinsrq" [instruction pinsrq <$> parse_reg_128_reg_64_imm_a] + ; gen_instruction "pinsrq" [ instruction pinsrq <$> parse_reg_128_reg_64_imm_a ] ; gen_instruction "mulpd" [ instruction mulpd <$> parse_reg_128_reg_128 ] ] ;; From 4a625669cfe0d1961c58459426d323f804a3047e Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Sun, 31 Dec 2023 19:01:54 +0300 Subject: [PATCH 03/10] fix: replace unsupported function --- asm/lib/interpreter/interpreter.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/asm/lib/interpreter/interpreter.ml b/asm/lib/interpreter/interpreter.ml index 9c76b8692..ff9db7057 100644 --- a/asm/lib/interpreter/interpreter.ml +++ b/asm/lib/interpreter/interpreter.ml @@ -133,8 +133,15 @@ let find_and_set_starting_label ast = ;; let get_next_statement_index ast current_index = + let find_index cond lst = + let rec helper index = function + | [] -> None + | x :: xs -> if cond x then Some index else helper (index + 1) xs + in + helper 0 lst + in let handle_label_jump label = - match List.find_index (fun x -> x = Label_decl label) ast with + match find_index (fun x -> x = Label_decl label) ast with | Some index -> let* _ = reset_label_to_jmp in return (index + 1) From 91341f6ca6db76c5b5852c5b8ba52b00241ec01f Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Sun, 31 Dec 2023 19:12:15 +0300 Subject: [PATCH 04/10] feat: add mli interfaces --- asm/lib/interpreter/containers.mli | 104 ++++++++++++++++++++++++++++ asm/lib/interpreter/interpreter.mli | 7 ++ asm/lib/interpreter/state.mli | 56 +++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 asm/lib/interpreter/containers.mli create mode 100644 asm/lib/interpreter/interpreter.mli create mode 100644 asm/lib/interpreter/state.mli diff --git a/asm/lib/interpreter/containers.mli b/asm/lib/interpreter/containers.mli new file mode 100644 index 000000000..35b3a0eac --- /dev/null +++ b/asm/lib/interpreter/containers.mli @@ -0,0 +1,104 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +module StringMap : + sig + type key = string + type 'a t = 'a Map.Make(String).t + val empty : 'a t + val is_empty : 'a t -> bool + val mem : key -> 'a t -> bool + val add : key -> 'a -> 'a t -> 'a t + val update : key -> ('a option -> 'a option) -> 'a t -> 'a t + val singleton : key -> 'a -> 'a t + val remove : key -> 'a t -> 'a t + val merge : + (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t + val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int + val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + val iter : (key -> 'a -> unit) -> 'a t -> unit + val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val for_all : (key -> 'a -> bool) -> 'a t -> bool + val exists : (key -> 'a -> bool) -> 'a t -> bool + val filter : (key -> 'a -> bool) -> 'a t -> 'a t + val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t + val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + val cardinal : 'a t -> int + val bindings : 'a t -> (key * 'a) list + val min_binding : 'a t -> key * 'a + val min_binding_opt : 'a t -> (key * 'a) option + val max_binding : 'a t -> key * 'a + val max_binding_opt : 'a t -> (key * 'a) option + val choose : 'a t -> key * 'a + val choose_opt : 'a t -> (key * 'a) option + val split : key -> 'a t -> 'a t * 'a option * 'a t + val find : key -> 'a t -> 'a + val find_opt : key -> 'a t -> 'a option + val find_first : (key -> bool) -> 'a t -> key * 'a + val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option + val find_last : (key -> bool) -> 'a t -> key * 'a + val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option + val map : ('a -> 'b) -> 'a t -> 'b t + val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t + val to_seq : 'a t -> (key * 'a) Seq.t + val to_rev_seq : 'a t -> (key * 'a) Seq.t + val to_seq_from : key -> 'a t -> (key * 'a) Seq.t + val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t + end +module IntMap : + sig + type key = int + type 'a t = 'a Map.Make(Int).t + val empty : 'a t + val is_empty : 'a t -> bool + val mem : key -> 'a t -> bool + val add : key -> 'a -> 'a t -> 'a t + val update : key -> ('a option -> 'a option) -> 'a t -> 'a t + val singleton : key -> 'a -> 'a t + val remove : key -> 'a t -> 'a t + val merge : + (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t + val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int + val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + val iter : (key -> 'a -> unit) -> 'a t -> unit + val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val for_all : (key -> 'a -> bool) -> 'a t -> bool + val exists : (key -> 'a -> bool) -> 'a t -> bool + val filter : (key -> 'a -> bool) -> 'a t -> 'a t + val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t + val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + val cardinal : 'a t -> int + val bindings : 'a t -> (key * 'a) list + val min_binding : 'a t -> key * 'a + val min_binding_opt : 'a t -> (key * 'a) option + val max_binding : 'a t -> key * 'a + val max_binding_opt : 'a t -> (key * 'a) option + val choose : 'a t -> key * 'a + val choose_opt : 'a t -> (key * 'a) option + val split : key -> 'a t -> 'a t * 'a option * 'a t + val find : key -> 'a t -> 'a + val find_opt : key -> 'a t -> 'a option + val find_first : (key -> bool) -> 'a t -> key * 'a + val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option + val find_last : (key -> bool) -> 'a t -> key * 'a + val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option + val map : ('a -> 'b) -> 'a t -> 'b t + val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t + val to_seq : 'a t -> (key * 'a) Seq.t + val to_rev_seq : 'a t -> (key * 'a) Seq.t + val to_seq_from : key -> 'a t -> (key * 'a) Seq.t + val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t + end +module ListStack : + sig + type 'a t = 'a list + val empty : 'a list + val push : 'a -> 'a list -> 'a list + val peek : 'a list -> 'a option + val pop : 'a list -> 'a list option + end diff --git a/asm/lib/interpreter/interpreter.mli b/asm/lib/interpreter/interpreter.mli new file mode 100644 index 000000000..58d6a30e4 --- /dev/null +++ b/asm/lib/interpreter/interpreter.mli @@ -0,0 +1,7 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +val eval_ast : + Ast.statement list -> (State.GlobalState.t, unit) State.StateErrorMonad.t +module State = State diff --git a/asm/lib/interpreter/state.mli b/asm/lib/interpreter/state.mli new file mode 100644 index 000000000..4737c6e42 --- /dev/null +++ b/asm/lib/interpreter/state.mli @@ -0,0 +1,56 @@ +(** Copyright 2023-2024, Vadim Yakshigulov *) + +(** SPDX-License-Identifier: LGPL-3.0-or-later *) + +module StateErrorMonad : + sig + type ('st, 'a) t = 'st -> 'st * ('a, string) result + val return : 'a -> 'b -> 'b * ('a, 'c) result + val fail : 'a -> 'b -> 'b * ('c, 'a) result + val ( >>= ) : ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t + val read : ('st, 'st) t + val write : 'st -> ('st, unit) t + val run : ('st, 'a) t -> 'st -> 'st * ('a, string) result + val ( let* ) : ('a, 'b) t -> ('b -> ('a, 'c) t) -> ('a, 'c) t + end +module GlobalState : + sig + type t = { + registers : int Containers.StringMap.t; + xmm_registers : (int * int) Containers.StringMap.t; + stack : int list; + label_to_jmp : string option; + zero_flag : int; + carry_flag : int; + exit_code : int option; + } + val initialize_registers_with : + (string -> bool) -> 'a -> 'a Containers.StringMap.t + val initialize_registers : int Containers.StringMap.t + val initialize_xmm_registers : (int * int) Containers.StringMap.t + val initial_state : t + val update : + ('a -> ('a, 'a) StateErrorMonad.t) -> ('a, unit) StateErrorMonad.t + val show : t -> string + end +val read_label_to_jmp : (GlobalState.t, string option) StateErrorMonad.t +val read_zero_flag : (GlobalState.t, int) StateErrorMonad.t +val read_carry_flag : (GlobalState.t, int) StateErrorMonad.t +val peek_reg : (GlobalState.t, int option) StateErrorMonad.t +val read_generic_reg : + 'a Ast.register -> + ('b -> 'c Containers.StringMap.t) -> ('b, 'c) StateErrorMonad.t +val read_reg : 'a Ast.register -> (GlobalState.t, int) StateErrorMonad.t +val read_xmm_reg : + 'a Ast.register -> (GlobalState.t, int * int) StateErrorMonad.t +val write_reg : + 'a Ast.register -> int -> (GlobalState.t, unit) StateErrorMonad.t +val write_xmm_reg : + 'a Ast.register -> int * int -> (GlobalState.t, unit) StateErrorMonad.t +val push_reg : int -> (GlobalState.t, unit) StateErrorMonad.t +val pop_to_reg : 'a Ast.register -> (GlobalState.t, unit) StateErrorMonad.t +val reset_label_to_jmp : (GlobalState.t, unit) StateErrorMonad.t +val write_label_to_jmp : string -> (GlobalState.t, unit) StateErrorMonad.t +val write_zero_flag : int -> (GlobalState.t, unit) StateErrorMonad.t +val write_carry_flag : int -> (GlobalState.t, unit) StateErrorMonad.t +val write_exit_code : int -> (GlobalState.t, unit) StateErrorMonad.t From 4c93ef1c6a15f0d69fb513541c2d4483a2b7902f Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Sun, 31 Dec 2023 19:14:32 +0300 Subject: [PATCH 05/10] reformat: reformat mli --- asm/lib/interpreter/containers.mli | 200 ++++++++++++++-------------- asm/lib/interpreter/interpreter.mli | 4 +- asm/lib/interpreter/state.mli | 83 ++++++------ 3 files changed, 146 insertions(+), 141 deletions(-) diff --git a/asm/lib/interpreter/containers.mli b/asm/lib/interpreter/containers.mli index 35b3a0eac..0e678c11c 100644 --- a/asm/lib/interpreter/containers.mli +++ b/asm/lib/interpreter/containers.mli @@ -2,103 +2,103 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -module StringMap : - sig - type key = string - type 'a t = 'a Map.Make(String).t - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : - (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t - end -module IntMap : - sig - type key = int - type 'a t = 'a Map.Make(Int).t - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : - (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t - end -module ListStack : - sig - type 'a t = 'a list - val empty : 'a list - val push : 'a -> 'a list -> 'a list - val peek : 'a list -> 'a option - val pop : 'a list -> 'a list option - end +module StringMap : sig + type key = string + type 'a t = 'a Map.Make(String).t + + val empty : 'a t + val is_empty : 'a t -> bool + val mem : key -> 'a t -> bool + val add : key -> 'a -> 'a t -> 'a t + val update : key -> ('a option -> 'a option) -> 'a t -> 'a t + val singleton : key -> 'a -> 'a t + val remove : key -> 'a t -> 'a t + val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t + val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int + val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + val iter : (key -> 'a -> unit) -> 'a t -> unit + val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val for_all : (key -> 'a -> bool) -> 'a t -> bool + val exists : (key -> 'a -> bool) -> 'a t -> bool + val filter : (key -> 'a -> bool) -> 'a t -> 'a t + val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t + val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + val cardinal : 'a t -> int + val bindings : 'a t -> (key * 'a) list + val min_binding : 'a t -> key * 'a + val min_binding_opt : 'a t -> (key * 'a) option + val max_binding : 'a t -> key * 'a + val max_binding_opt : 'a t -> (key * 'a) option + val choose : 'a t -> key * 'a + val choose_opt : 'a t -> (key * 'a) option + val split : key -> 'a t -> 'a t * 'a option * 'a t + val find : key -> 'a t -> 'a + val find_opt : key -> 'a t -> 'a option + val find_first : (key -> bool) -> 'a t -> key * 'a + val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option + val find_last : (key -> bool) -> 'a t -> key * 'a + val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option + val map : ('a -> 'b) -> 'a t -> 'b t + val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t + val to_seq : 'a t -> (key * 'a) Seq.t + val to_rev_seq : 'a t -> (key * 'a) Seq.t + val to_seq_from : key -> 'a t -> (key * 'a) Seq.t + val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t +end + +module IntMap : sig + type key = int + type 'a t = 'a Map.Make(Int).t + + val empty : 'a t + val is_empty : 'a t -> bool + val mem : key -> 'a t -> bool + val add : key -> 'a -> 'a t -> 'a t + val update : key -> ('a option -> 'a option) -> 'a t -> 'a t + val singleton : key -> 'a -> 'a t + val remove : key -> 'a t -> 'a t + val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t + val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t + val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int + val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool + val iter : (key -> 'a -> unit) -> 'a t -> unit + val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val for_all : (key -> 'a -> bool) -> 'a t -> bool + val exists : (key -> 'a -> bool) -> 'a t -> bool + val filter : (key -> 'a -> bool) -> 'a t -> 'a t + val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t + val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t + val cardinal : 'a t -> int + val bindings : 'a t -> (key * 'a) list + val min_binding : 'a t -> key * 'a + val min_binding_opt : 'a t -> (key * 'a) option + val max_binding : 'a t -> key * 'a + val max_binding_opt : 'a t -> (key * 'a) option + val choose : 'a t -> key * 'a + val choose_opt : 'a t -> (key * 'a) option + val split : key -> 'a t -> 'a t * 'a option * 'a t + val find : key -> 'a t -> 'a + val find_opt : key -> 'a t -> 'a option + val find_first : (key -> bool) -> 'a t -> key * 'a + val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option + val find_last : (key -> bool) -> 'a t -> key * 'a + val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option + val map : ('a -> 'b) -> 'a t -> 'b t + val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t + val to_seq : 'a t -> (key * 'a) Seq.t + val to_rev_seq : 'a t -> (key * 'a) Seq.t + val to_seq_from : key -> 'a t -> (key * 'a) Seq.t + val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t +end + +module ListStack : sig + type 'a t = 'a list + + val empty : 'a list + val push : 'a -> 'a list -> 'a list + val peek : 'a list -> 'a option + val pop : 'a list -> 'a list option +end diff --git a/asm/lib/interpreter/interpreter.mli b/asm/lib/interpreter/interpreter.mli index 58d6a30e4..d950e6d63 100644 --- a/asm/lib/interpreter/interpreter.mli +++ b/asm/lib/interpreter/interpreter.mli @@ -2,6 +2,6 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -val eval_ast : - Ast.statement list -> (State.GlobalState.t, unit) State.StateErrorMonad.t +val eval_ast : Ast.statement list -> (State.GlobalState.t, unit) State.StateErrorMonad.t + module State = State diff --git a/asm/lib/interpreter/state.mli b/asm/lib/interpreter/state.mli index 4737c6e42..4ce5c04e9 100644 --- a/asm/lib/interpreter/state.mli +++ b/asm/lib/interpreter/state.mli @@ -2,51 +2,56 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -module StateErrorMonad : - sig - type ('st, 'a) t = 'st -> 'st * ('a, string) result - val return : 'a -> 'b -> 'b * ('a, 'c) result - val fail : 'a -> 'b -> 'b * ('c, 'a) result - val ( >>= ) : ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t - val read : ('st, 'st) t - val write : 'st -> ('st, unit) t - val run : ('st, 'a) t -> 'st -> 'st * ('a, string) result - val ( let* ) : ('a, 'b) t -> ('b -> ('a, 'c) t) -> ('a, 'c) t - end -module GlobalState : - sig - type t = { - registers : int Containers.StringMap.t; - xmm_registers : (int * int) Containers.StringMap.t; - stack : int list; - label_to_jmp : string option; - zero_flag : int; - carry_flag : int; - exit_code : int option; +module StateErrorMonad : sig + type ('st, 'a) t = 'st -> 'st * ('a, string) result + + val return : 'a -> 'b -> 'b * ('a, 'c) result + val fail : 'a -> 'b -> 'b * ('c, 'a) result + val ( >>= ) : ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t + val read : ('st, 'st) t + val write : 'st -> ('st, unit) t + val run : ('st, 'a) t -> 'st -> 'st * ('a, string) result + val ( let* ) : ('a, 'b) t -> ('b -> ('a, 'c) t) -> ('a, 'c) t +end + +module GlobalState : sig + type t = + { registers : int Containers.StringMap.t + ; xmm_registers : (int * int) Containers.StringMap.t + ; stack : int list + ; label_to_jmp : string option + ; zero_flag : int + ; carry_flag : int + ; exit_code : int option } - val initialize_registers_with : - (string -> bool) -> 'a -> 'a Containers.StringMap.t - val initialize_registers : int Containers.StringMap.t - val initialize_xmm_registers : (int * int) Containers.StringMap.t - val initial_state : t - val update : - ('a -> ('a, 'a) StateErrorMonad.t) -> ('a, unit) StateErrorMonad.t - val show : t -> string - end + + val initialize_registers_with : (string -> bool) -> 'a -> 'a Containers.StringMap.t + val initialize_registers : int Containers.StringMap.t + val initialize_xmm_registers : (int * int) Containers.StringMap.t + val initial_state : t + val update : ('a -> ('a, 'a) StateErrorMonad.t) -> ('a, unit) StateErrorMonad.t + val show : t -> string +end + val read_label_to_jmp : (GlobalState.t, string option) StateErrorMonad.t val read_zero_flag : (GlobalState.t, int) StateErrorMonad.t val read_carry_flag : (GlobalState.t, int) StateErrorMonad.t val peek_reg : (GlobalState.t, int option) StateErrorMonad.t -val read_generic_reg : - 'a Ast.register -> - ('b -> 'c Containers.StringMap.t) -> ('b, 'c) StateErrorMonad.t + +val read_generic_reg + : 'a Ast.register + -> ('b -> 'c Containers.StringMap.t) + -> ('b, 'c) StateErrorMonad.t + val read_reg : 'a Ast.register -> (GlobalState.t, int) StateErrorMonad.t -val read_xmm_reg : - 'a Ast.register -> (GlobalState.t, int * int) StateErrorMonad.t -val write_reg : - 'a Ast.register -> int -> (GlobalState.t, unit) StateErrorMonad.t -val write_xmm_reg : - 'a Ast.register -> int * int -> (GlobalState.t, unit) StateErrorMonad.t +val read_xmm_reg : 'a Ast.register -> (GlobalState.t, int * int) StateErrorMonad.t +val write_reg : 'a Ast.register -> int -> (GlobalState.t, unit) StateErrorMonad.t + +val write_xmm_reg + : 'a Ast.register + -> int * int + -> (GlobalState.t, unit) StateErrorMonad.t + val push_reg : int -> (GlobalState.t, unit) StateErrorMonad.t val pop_to_reg : 'a Ast.register -> (GlobalState.t, unit) StateErrorMonad.t val reset_label_to_jmp : (GlobalState.t, unit) StateErrorMonad.t From 5c516908612a945f21abb55e5204cd820ec0021c Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Fri, 5 Jan 2024 14:45:59 -0800 Subject: [PATCH 06/10] feat: add matrix and vector muliplication --- asm/bin/demoInterpreter.t | 122 +++++++++++++++-------------- asm/bin/demoParser.t | 36 +-------- asm/bin/dune | 8 +- asm/bin/sources/fib.asm | 29 +++++++ asm/bin/sources/matrix.asm | 42 ++++++++++ asm/bin/sources/scalar.asm | 23 ++++++ asm/lib/ast/ast.ml | 1 + asm/lib/interpreter/containers.mli | 88 +-------------------- asm/lib/interpreter/interpreter.ml | 16 ++-- asm/lib/parser/statement.ml | 1 + 10 files changed, 184 insertions(+), 182 deletions(-) create mode 100644 asm/bin/sources/fib.asm create mode 100644 asm/bin/sources/matrix.asm create mode 100644 asm/bin/sources/scalar.asm diff --git a/asm/bin/demoInterpreter.t b/asm/bin/demoInterpreter.t index 7043bb818..9bb6e9cf3 100644 --- a/asm/bin/demoInterpreter.t +++ b/asm/bin/demoInterpreter.t @@ -1,34 +1,5 @@ - $ ./demoInterpreter.exe <<- EOF - > section .text - > global _start - > _start: - > ; Инициализируем регистры для хранения предыдущих двух чисел Фибоначчи - > mov rcx, 10 ; Ищем 10-ое число Фибоначчи - > mov rax, 0 ; F(0) - > mov rbx, 1 ; F(1) - > - > cmp rcx, 1 - > jle exit ; Если n <= 1, результат уже в rax - > sub rcx, 1 ; Первое число Фибоначчи уже в rax, начинаем с F(2) - > - > fib_loop: - > add rax, rbx ; F(n) = F(n-1) + F(n-2) - > ; Обмен значениями rax и rbx, используя xor swap trick - > xor rax, rbx - > xor rbx, rax - > xor rax, rbx - > ; Теперь rax содержит F(n-1), rbx содержит F(n) - > - > sub rcx, 1 - > cmp rcx, 0 - > jne fib_loop - > - > exit: - > ; Завершение программы и возврат значения в rax - > mov rdi, 0 ; Код возврата - > mov rax, 60 ; syscall номер для exit - > syscall - > EOF +Поиск n-ого числа Фибоначчи, где n -- значение в rcx + $ ./demoInterpreter.exe < ./sources/fib.asm (Directive (Section .text)) (Directive (Global _start)) (LabelDecl _start) @@ -80,32 +51,9 @@ Label to jump: None Zero flag: 1 - $ ./demoInterpreter.exe <<- EOF - > ; Считает скалярное произведение двух векторов (1, 2) и (3, 4) в xmm0 и xmm1 - > ; Результат кладет в rdx - > global redefine_start_point - > section .text - > redefine_start_point: - > mov rbx, 1 - > mov rcx, 2 - > pinsrq xmm0, rbx, 1 - > pinsrq xmm0, rcx, 0 - > mov rbx, 3 - > mov rcx, 4 - > pinsrq xmm1, rbx, 1 - > pinsrq xmm1, rcx, 0 - > - > mulpd xmm0, xmm1 - > movapd xmm2, xmm0 - > punpckhqdq xmm2, xmm2 - > addpd xmm0, xmm2 - > movq rdx, xmm0 - > exit: - > ; Завершение программы и возврат значения в rax - > mov rdi, 0 ; Код возврата - > mov rax, 60 ; syscall номер для exit - > syscall - > EOF +Вычисление произведения двух векторов (1, 2) и (3, 4) в xmm0 и xmm1 +Результат лежит в rdx + $ ./demoInterpreter.exe < ./sources/scalar.asm (Directive (Global redefine_start_point)) (Directive (Section .text)) (LabelDecl redefine_start_point) @@ -155,3 +103,63 @@ Stack: Label to jump: None Zero flag: 0 + +Умножение матрицы (1, 2) - xmm0 на вектор (6) - в xmm2 +| (3, 4) - xmm1 (7) +Результат - вектор (20) в xmm7 +| (46) + $ ./demoInterpreter.exe < ./sources/matrix.asm + (Directive (Global _start)) + (Directive (Section .text)) + (LabelDecl _start) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 1))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 2))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm0, Rbx, (Imm_int 1))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm0, Rcx, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 3))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 4))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm1, Rbx, (Imm_int 1))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm1, Rcx, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 6))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 7))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm2, Rbx, (Imm_int 1))))) + (Instruction (Pinsrq (Reg_128_reg_64_imm_a (Xmm2, Rcx, (Imm_int 0))))) + (Instruction (Mulpd (Reg_128_reg_128 (Xmm0, Xmm2)))) + (Instruction (Haddpd (Reg_128_reg_128 (Xmm0, Xmm0)))) + (Instruction (Mulpd (Reg_128_reg_128 (Xmm1, Xmm2)))) + (Instruction (Haddpd (Reg_128_reg_128 (Xmm1, Xmm1)))) + (Instruction (Movapd (Reg_128_reg_128 (Xmm7, Xmm0)))) + (Instruction (Punpckhqdq (Reg_128_reg_128 (Xmm7, Xmm1)))) + (LabelDecl exit) + (Instruction (Mov (Reg_64_imm_a (Rdi, (Imm_int 0))))) + (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) + (Instruction (Syscall (Nothing))) + Registers: + Eax: 0 + Ebp: 0 + Ebx: 0 + Ecx: 0 + Edi: 0 + Edx: 0 + Esi: 0 + Esp: 0 + Rax: 60 + Rbp: 0 + Rbx: 6 + Rcx: 7 + Rdi: 0 + Rdx: 0 + Rsi: 0 + Rsp: 0 + XMM Registers: + Xmm0: (20, 20) + Xmm1: (46, 46) + Xmm2: (6, 7) + Xmm3: (0, 0) + Xmm4: (0, 0) + Xmm5: (0, 0) + Xmm6: (0, 0) + Xmm7: (20, 46) + Stack: + Label to jump: None + Zero flag: 0 diff --git a/asm/bin/demoParser.t b/asm/bin/demoParser.t index 56426e1ca..ff795b2b1 100644 --- a/asm/bin/demoParser.t +++ b/asm/bin/demoParser.t @@ -1,38 +1,8 @@ - $ ./demoParser.exe <<- EOF - > section .text - > global _start - > _start: - > ; Инициализируем регистры для хранения предыдущих двух чисел Фибоначчи - > mov rcx, 11 ; Ишем 10-ое число Фибоначчи - > mov rax, 0 ; F(0) - > mov rbx, 1 ; F(1) - > - > cmp rcx, 1 - > jle exit ; Если n <= 1, результат уже в rax - > sub rcx, 1 ; Первое число Фибоначчи уже в rax, начинаем с F(2) - > - > fib_loop: - > add rax, rbx ; F(n) = F(n-1) + F(n-2) - > ; Обмен значениями rax и rbx, используя xor swap trick - > xor rax, rbx - > xor rbx, rax - > xor rax, rbx - > ; Теперь rax содержит F(n-1), rbx содержит F(n) - > - > sub rcx, 1 - > cmp rcx, 1 - > jne fib_loop - > - > exit: - > ; Завершение программы и возврат значения в rax - > mov rdi, 0 ; Код возврата - > mov rax, 60 ; syscall номер для exit - > syscall - > EOF + $ ./demoParser.exe < ./sources/fib.asm (Directive (Section .text)) (Directive (Global _start)) (LabelDecl _start) - (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 11))))) + (Instruction (Mov (Reg_64_imm_a (Rcx, (Imm_int 10))))) (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 0))))) (Instruction (Mov (Reg_64_imm_a (Rbx, (Imm_int 1))))) (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 1))))) @@ -44,7 +14,7 @@ (Instruction (Xor (Reg_64_reg_64 (Rbx, Rax)))) (Instruction (Xor (Reg_64_reg_64 (Rax, Rbx)))) (Instruction (Sub (Reg_64_imm_a (Rcx, (Imm_int 1))))) - (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 1))))) + (Instruction (Cmp (Reg_64_imm_a (Rcx, (Imm_int 0))))) (Instruction (Jne (Label fib_loop))) (LabelDecl exit) (Instruction (Mov (Reg_64_imm_a (Rdi, (Imm_int 0))))) diff --git a/asm/bin/dune b/asm/bin/dune index a8bd7141d..01c29d800 100644 --- a/asm/bin/dune +++ b/asm/bin/dune @@ -15,4 +15,10 @@ (backend bisect_ppx))) (cram - (deps ./demoParser.exe ./demoInterpreter.exe)) + (deps + ./demoParser.exe + ./demoInterpreter.exe + ./sources/fib.asm + ./sources/scalar.asm + ./sources/matrix.asm + )) diff --git a/asm/bin/sources/fib.asm b/asm/bin/sources/fib.asm new file mode 100644 index 000000000..1f5aa87bd --- /dev/null +++ b/asm/bin/sources/fib.asm @@ -0,0 +1,29 @@ +; Ищем n-ое число Фибоначчи, где n -- значение в rcx +section .text +global _start +_start: + ; Инициализируем регистры для хранения предыдущих двух чисел Фибоначчи + mov rcx, 10 ; Количество итераций + mov rax, 0 ; F(0) + mov rbx, 1 ; F(1) + + cmp rcx, 1 + jle exit ; Если n <= 1, результат уже в rax + sub rcx, 1 ; Первое число Фибоначчи уже в rax, начинаем с F(2) + +fib_loop: + add rax, rbx ; F(n) = F(n-1) + F(n-2) + ; Обмен значениями rax и rbx, используя xor swap trick + xor rax, rbx + xor rbx, rax + xor rax, rbx + ; Теперь rax содержит F(n-1), rbx содержит F(n) + + sub rcx, 1 + cmp rcx, 0 + jne fib_loop + +exit: + mov rdi, 0 ; Код возврата + mov rax, 60 ; syscall номер для exit + syscall diff --git a/asm/bin/sources/matrix.asm b/asm/bin/sources/matrix.asm new file mode 100644 index 000000000..2c498f01c --- /dev/null +++ b/asm/bin/sources/matrix.asm @@ -0,0 +1,42 @@ +; Умножение матрицы (1, 2) - xmm0 на вектор (6) - в xmm2 +; (3, 4) - xmm1 (7) +; Результат - вектор (20) в xmm7 +; (46) + +global _start +section .text +_start: + ; Подготовка матрицы A + mov rbx, 1 + mov rcx, 2 + pinsrq xmm0, rbx, 1 + pinsrq xmm0, rcx, 0 + mov rbx, 3 + mov rcx, 4 + pinsrq xmm1, rbx, 1 + pinsrq xmm1, rcx, 0 + + ; Подготовка вектора v + mov rbx, 6 + mov rcx, 7 + pinsrq xmm2, rbx, 1 ; Загрузка 6 в xmm2 + pinsrq xmm2, rcx, 0 ; Загрузка 7 в xmm2 + + ; Умножение первой строки матрицы A на вектор v + mulpd xmm0, xmm2 + ; Горизонтальное сложение для получения результата умножения первой строки на вектор + haddpd xmm0, xmm0 + + ; Умножение второй строки матрицы A на вектор v + mulpd xmm1, xmm2 + ; Горизонтальное сложение для получения результата умножения второй строки на вектор + haddpd xmm1, xmm1 + + ; Сохранение результатов в xmm7 + movapd xmm7, xmm0 + punpckhqdq xmm7, xmm1 + +exit: + mov rdi, 0 ; Код возврата + mov rax, 60 ; syscall номер для exit + syscall diff --git a/asm/bin/sources/scalar.asm b/asm/bin/sources/scalar.asm new file mode 100644 index 000000000..71d98522c --- /dev/null +++ b/asm/bin/sources/scalar.asm @@ -0,0 +1,23 @@ +; Считает скалярное произведение двух векторов (1, 2) и (3, 4) в xmm0 и xmm1 +; Результат кладет в rdx +global redefine_start_point +section .text +redefine_start_point: + mov rbx, 1 + mov rcx, 2 + pinsrq xmm0, rbx, 1 + pinsrq xmm0, rcx, 0 + mov rbx, 3 + mov rcx, 4 + pinsrq xmm1, rbx, 1 + pinsrq xmm1, rcx, 0 + + mulpd xmm0, xmm1 + movapd xmm2, xmm0 + punpckhqdq xmm2, xmm2 + addpd xmm0, xmm2 + movq rdx, xmm0 +exit: + mov rdi, 0 ; Код возврата + mov rax, 60 ; syscall номер для exit + syscall diff --git a/asm/lib/ast/ast.ml b/asm/lib/ast/ast.ml index 55d6a247f..89e89547c 100644 --- a/asm/lib/ast/ast.ml +++ b/asm/lib/ast/ast.ml @@ -83,6 +83,7 @@ type _ mnemonic = | Pinsrq : [< `Reg_128_reg_64_imm_a ] mnemonic | Addpd : [< `Reg_128_reg_128 ] mnemonic | Mulpd : [< `Reg_128_reg_128 ] mnemonic + | Haddpd : [< `Reg_128_reg_128 ] mnemonic (** Not sure that these instructions can really be used with integer values in xmm registers. The specification of the instructions is a complete mess*) [@@deriving variants] diff --git a/asm/lib/interpreter/containers.mli b/asm/lib/interpreter/containers.mli index 0e678c11c..e6a903a61 100644 --- a/asm/lib/interpreter/containers.mli +++ b/asm/lib/interpreter/containers.mli @@ -3,95 +3,11 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) module StringMap : sig - type key = string - type 'a t = 'a Map.Make(String).t - - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t + include Map.S with type key = string end module IntMap : sig - type key = int - type 'a t = 'a Map.Make(Int).t - - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t + include Map.S with type key = int end module ListStack : sig diff --git a/asm/lib/interpreter/interpreter.ml b/asm/lib/interpreter/interpreter.ml index ff9db7057..ac0171487 100644 --- a/asm/lib/interpreter/interpreter.ml +++ b/asm/lib/interpreter/interpreter.ml @@ -103,20 +103,26 @@ let eval_statement = function write_xmm_reg r1 (high1 * high2, low1 * low2)) | Instruction (Pinsrq, args) -> (match args with - | Reg_128_reg_64_imm_a (r1, r2, Imm_int 0) -> + | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when (i land 1) = 0 -> let* high, _low = read_xmm_reg r1 in let* v2 = read_reg r2 in write_xmm_reg r1 (high, v2) - | Reg_128_reg_64_imm_a (r1, r2, Imm_int 1) -> + | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when (i land 1) = 1 -> let* _high, low = read_xmm_reg r1 in let* v2 = read_reg r2 in write_xmm_reg r1 (v2, low) - | _ -> fail "Undefined instruction") + | _ -> fail "Unsupported instruction operands") | Instruction (Movapd, args) -> (match args with | Reg_128_reg_128 (r1, r2) -> let* high1, low1 = read_xmm_reg r2 in write_xmm_reg r1 (high1, low1)) + | Instruction (Haddpd, args) -> + (match args with + | Reg_128_reg_128 (r1, r2) -> + let* high1, low1 = read_xmm_reg r1 in + let* high2, low2 = read_xmm_reg r2 in + write_xmm_reg r1 (high2 + low2, high1 + low1)) | Directive _ -> ignore | Label_decl _ -> ignore ;; @@ -147,8 +153,8 @@ let get_next_statement_index ast current_index = return (index + 1) | None -> fail "Can't jump to undefined label" in - let* state = read in - match state.label_to_jmp with + let* maybe_label = read_label_to_jmp in + match maybe_label with | Some label_to_jmp -> handle_label_jump label_to_jmp | None -> return (current_index + 1) ;; diff --git a/asm/lib/parser/statement.ml b/asm/lib/parser/statement.ml index e3889518d..3b56af899 100644 --- a/asm/lib/parser/statement.ml +++ b/asm/lib/parser/statement.ml @@ -39,6 +39,7 @@ let parse_instruction = ; gen_instruction "addpd" [ instruction addpd <$> parse_reg_128_reg_128 ] ; gen_instruction "pinsrq" [ instruction pinsrq <$> parse_reg_128_reg_64_imm_a ] ; gen_instruction "mulpd" [ instruction mulpd <$> parse_reg_128_reg_128 ] + ; gen_instruction "haddpd" [ instruction haddpd <$> parse_reg_128_reg_128 ] ] ;; From 834f7fc9496d19ee9b5dda96939b8b72e5f2c231 Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Fri, 5 Jan 2024 14:49:35 -0800 Subject: [PATCH 07/10] fix: reformat code for linter --- asm/bin/dune | 13 ++++++------- asm/lib/interpreter/interpreter.ml | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/asm/bin/dune b/asm/bin/dune index 01c29d800..87bdbdae0 100644 --- a/asm/bin/dune +++ b/asm/bin/dune @@ -15,10 +15,9 @@ (backend bisect_ppx))) (cram - (deps - ./demoParser.exe - ./demoInterpreter.exe - ./sources/fib.asm - ./sources/scalar.asm - ./sources/matrix.asm - )) + (deps + ./demoParser.exe + ./demoInterpreter.exe + ./sources/fib.asm + ./sources/scalar.asm + ./sources/matrix.asm)) diff --git a/asm/lib/interpreter/interpreter.ml b/asm/lib/interpreter/interpreter.ml index ac0171487..ae269bf93 100644 --- a/asm/lib/interpreter/interpreter.ml +++ b/asm/lib/interpreter/interpreter.ml @@ -103,11 +103,11 @@ let eval_statement = function write_xmm_reg r1 (high1 * high2, low1 * low2)) | Instruction (Pinsrq, args) -> (match args with - | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when (i land 1) = 0 -> + | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when i land 1 = 0 -> let* high, _low = read_xmm_reg r1 in let* v2 = read_reg r2 in write_xmm_reg r1 (high, v2) - | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when (i land 1) = 1 -> + | Reg_128_reg_64_imm_a (r1, r2, Imm_int i) when i land 1 = 1 -> let* _high, low = read_xmm_reg r1 in let* v2 = read_reg r2 in write_xmm_reg r1 (v2, low) From efa97b17db626926dace6d13d9ec8e5731e213ed Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Mon, 8 Jan 2024 14:36:23 -0800 Subject: [PATCH 08/10] refactor: remove unused 32 bit registers --- asm/bin/demoInterpreter.t | 24 ------------------------ asm/lib/ast/ast.ml | 25 ------------------------- asm/lib/parser/operand.ml | 10 ---------- asm/lib/parser/operand.mli | 5 ----- asm/lib/parser/register.ml | 18 ------------------ asm/lib/parser/register.mli | 2 -- 6 files changed, 84 deletions(-) diff --git a/asm/bin/demoInterpreter.t b/asm/bin/demoInterpreter.t index 9bb6e9cf3..b69206823 100644 --- a/asm/bin/demoInterpreter.t +++ b/asm/bin/demoInterpreter.t @@ -22,14 +22,6 @@ (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) (Instruction (Syscall (Nothing))) Registers: - Eax: 0 - Ebp: 0 - Ebx: 0 - Ecx: 0 - Edi: 0 - Edx: 0 - Esi: 0 - Esp: 0 Rax: 60 Rbp: 0 Rbx: 55 @@ -75,14 +67,6 @@ (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) (Instruction (Syscall (Nothing))) Registers: - Eax: 0 - Ebp: 0 - Ebx: 0 - Ecx: 0 - Edi: 0 - Edx: 0 - Esi: 0 - Esp: 0 Rax: 60 Rbp: 0 Rbx: 3 @@ -135,14 +119,6 @@ (Instruction (Mov (Reg_64_imm_a (Rax, (Imm_int 60))))) (Instruction (Syscall (Nothing))) Registers: - Eax: 0 - Ebp: 0 - Ebx: 0 - Ecx: 0 - Edi: 0 - Edx: 0 - Esi: 0 - Esp: 0 Rax: 60 Rbp: 0 Rbx: 6 diff --git a/asm/lib/ast/ast.ml b/asm/lib/ast/ast.ml index 89e89547c..8c7124653 100644 --- a/asm/lib/ast/ast.ml +++ b/asm/lib/ast/ast.ml @@ -2,19 +2,10 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -type i32 type i64 type i128 type _ register = - | Eax : i32 register - | Ebx : i32 register - | Ecx : i32 register - | Edx : i32 register - | Esi : i32 register - | Edi : i32 register - | Esp : i32 register - | Ebp : i32 register | Rax : i64 register | Rbx : i64 register | Rcx : i64 register @@ -37,19 +28,14 @@ type _ immediate = Imm_int of int [@@deriving variants] type 'a register_ref = Register_ref of 'a register [@@deriving variants] type _ operand = - | Reg_32_reg_32 : i32 register * i32 register -> [> `Reg_32_reg_32 ] operand | Reg_64_reg_64 : i64 register * i64 register -> [> `Reg_64_reg_64 ] operand (** Double register operands *) - | Mem_32_mem_32 : i32 register_ref * i32 register_ref -> [> `Mem_32_mem_32 ] operand | Mem_64_mem_64 : i64 register_ref * i64 register_ref -> [> `Mem_64_mem_64 ] operand (** Double memory operands *) - | Reg_32_imm_a : i32 register * _ immediate -> [> `Reg_32_imm_a ] operand | Reg_64_imm_a : i64 register * _ immediate -> [> `Reg_64_imm_a ] operand (** Mixed double operands *) | Imm_a : _ immediate -> [> `Imm_a ] operand (** Single immidiate operand *) - | Reg_32 : i32 register -> [> `Reg_32 ] operand | Reg_64 : i64 register -> [> `Reg_64 ] operand (** Single register operand*) - | Mem_32 : i32 register_ref -> [> `Mem_32 ] operand | Mem_64 : i64 register_ref -> [> `Mem_64 ] operand (** Single memory operand*) | Nothing : [> `Nothing ] operand (** Mnemonic without operand (e.g Ret)*) | Label : string -> [> `Label ] operand (** Label operand (e.g Jmp lbl) *) @@ -123,29 +109,18 @@ type register_wrapper = Wregister : 'a register -> register_wrapper let show_operand (Wargs op) = match op with - | Reg_32 x -> Printf.sprintf {|(Rezg_32 %s)|} (show_register x) | Reg_64 x -> Printf.sprintf {|(Reg_64 %s)|} (show_register x) - | Mem_32 x -> Printf.sprintf {|(Mem_32 %s)|} (show_register_ref x) | Mem_64 x -> Printf.sprintf {|(Mem_64 %s)|} (show_register_ref x) - | Mem_32_mem_32 (x, y) -> - Printf.sprintf - {|(Mem_32_mem_32 (%s, %s))|} - (show_register_ref x) - (show_register_ref y) | Mem_64_mem_64 (x, y) -> Printf.sprintf {|(Mem_64_mem_64 (%s, %s))|} (show_register_ref x) (show_register_ref y) - | Reg_32_reg_32 (x, y) -> - Printf.sprintf {|(Reg_32_reg_32 (%s, %s))|} (show_register x) (show_register y) | Reg_64_reg_64 (x, y) -> Printf.sprintf {|(Reg_64_reg_64 (%s, %s))|} (show_register x) (show_register y) | Imm_a x -> Printf.sprintf {|(Imm_a %s)|} (show_immediate x) | Label x -> Printf.sprintf {|(Label %s)|} x | Nothing -> "(Nothing)" - | Reg_32_imm_a (x, y) -> - Printf.sprintf {|(Reg_32_imm_a (%s, %s))|} (show_register x) (show_immediate y) | Reg_64_imm_a (x, y) -> Printf.sprintf {|(Reg_64_imm_a (%s, %s))|} (show_register x) (show_immediate y) | Reg_128_reg_64 (x, y) -> diff --git a/asm/lib/parser/operand.ml b/asm/lib/parser/operand.ml index 265ddac3b..0519145fd 100644 --- a/asm/lib/parser/operand.ml +++ b/asm/lib/parser/operand.ml @@ -8,32 +8,22 @@ open Common open Register open Immediate -let parse_reg_32 = reg_32 <$> parse_32_register let parse_reg_64 = reg_64 <$> parse_64_register let parse_reg_128 = reg_128 <$> parse_128_register let parse_imm_a = imm_a <$> parse_immidiate -let parse_mem_32_mem_32 = - lift2 mem_32_mem_32 parse_32_register_ref (comma *> parse_32_register_ref) -;; let parse_mem_64_mem_64 = lift2 mem_64_mem_64 parse_64_register_ref (comma *> parse_64_register_ref) ;; -let parse_reg_32_reg_32 = - lift2 reg_32_reg_32 parse_32_register (comma *> parse_32_register) -;; - let parse_reg_64_reg_64 = lift2 reg_64_reg_64 parse_64_register (comma *> parse_64_register) ;; -let parse_mem_32 = mem_32 <$> parse_32_register_ref let parse_mem_64 = mem_64 <$> parse_64_register_ref let parse_label_operand = label <$> label_name let parse_nothing = return nothing -let parse_reg_32_imm_a = lift2 reg_32_imm_a parse_32_register (comma *> parse_immidiate) let parse_reg_64_imm_a = lift2 reg_64_imm_a parse_64_register (comma *> parse_immidiate) let parse_reg_128_reg_128 = diff --git a/asm/lib/parser/operand.mli b/asm/lib/parser/operand.mli index 9ab745725..933ae7545 100644 --- a/asm/lib/parser/operand.mli +++ b/asm/lib/parser/operand.mli @@ -2,19 +2,14 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -val parse_reg_32 : [ `Reg_32 ] Ast.operand Angstrom.t val parse_reg_64 : [ `Reg_64 ] Ast.operand Angstrom.t val parse_reg_128 : [ `Reg_128 ] Ast.operand Angstrom.t val parse_imm_a : [ `Imm_a ] Ast.operand Angstrom.t -val parse_mem_32_mem_32 : [ `Mem_32_mem_32 ] Ast.operand Angstrom.t val parse_mem_64_mem_64 : [ `Mem_64_mem_64 ] Ast.operand Angstrom.t -val parse_reg_32_reg_32 : [ `Reg_32_reg_32 ] Ast.operand Angstrom.t val parse_reg_64_reg_64 : [ `Reg_64_reg_64 ] Ast.operand Angstrom.t -val parse_mem_32 : [ `Mem_32 ] Ast.operand Angstrom.t val parse_mem_64 : [ `Mem_64 ] Ast.operand Angstrom.t val parse_label_operand : [ `Label ] Ast.operand Angstrom.t val parse_nothing : [ `Nothing ] Ast.operand Angstrom.t -val parse_reg_32_imm_a : [ `Reg_32_imm_a ] Ast.operand Angstrom.t val parse_reg_64_imm_a : [ `Reg_64_imm_a ] Ast.operand Angstrom.t val parse_reg_128_reg_128 : [ `Reg_128_reg_128 ] Ast.operand Angstrom.t val parse_reg_128_reg_64 : [ `Reg_128_reg_64 ] Ast.operand Angstrom.t diff --git a/asm/lib/parser/register.ml b/asm/lib/parser/register.ml index 8d09579e6..4368ecd8b 100644 --- a/asm/lib/parser/register.ml +++ b/asm/lib/parser/register.ml @@ -6,20 +6,6 @@ open Common open Angstrom open Ast -let parse_32_register = - choice - ~failure_msg:"parse_32_register" - [ string_ci "eax" *> return eax - ; string_ci "ebx" *> return ebx - ; string_ci "ecx" *> return ecx - ; string_ci "edx" *> return edx - ; string_ci "esp" *> return esp - ; string_ci "ebp" *> return ebp - ; string_ci "esi" *> return esi - ; string_ci "edi" *> return edi - ] -;; - let parse_64_register = choice ~failure_msg:"parse_64_register" @@ -50,10 +36,6 @@ let parse_128_register = let between_brackets parser = between (char '[') (char ']') parser "between_brackets" -let parse_32_register_ref = - between_brackets parse_32_register >>| register_ref "parse_32_register_ref" -;; - let parse_64_register_ref = between_brackets parse_64_register >>| register_ref "parse_64_register_ref" ;; diff --git a/asm/lib/parser/register.mli b/asm/lib/parser/register.mli index 3d6b213da..3eb044f7c 100644 --- a/asm/lib/parser/register.mli +++ b/asm/lib/parser/register.mli @@ -2,10 +2,8 @@ (** SPDX-License-Identifier: LGPL-3.0-or-later *) -val parse_32_register : Ast.i32 Ast.register Angstrom.t val parse_64_register : Ast.i64 Ast.register Angstrom.t val parse_128_register : Ast.i128 Ast.register Angstrom.t val between_brackets : 'a Angstrom.t -> 'a Angstrom.t -val parse_32_register_ref : Ast.i32 Ast.register_ref Angstrom.t val parse_64_register_ref : Ast.i64 Ast.register_ref Angstrom.t val parse_128_register_ref : Ast.i128 Ast.register_ref Angstrom.t From 775bf9e2656ea017f94dad25f8fb4441aac53371 Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov Date: Mon, 8 Jan 2024 14:49:26 -0800 Subject: [PATCH 09/10] fix: reformat code for linter --- asm/lib/parser/operand.ml | 1 - asm/lib/parser/parser.ml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/asm/lib/parser/operand.ml b/asm/lib/parser/operand.ml index 0519145fd..6b4ba89a1 100644 --- a/asm/lib/parser/operand.ml +++ b/asm/lib/parser/operand.ml @@ -12,7 +12,6 @@ let parse_reg_64 = reg_64 <$> parse_64_register let parse_reg_128 = reg_128 <$> parse_128_register let parse_imm_a = imm_a <$> parse_immidiate - let parse_mem_64_mem_64 = lift2 mem_64_mem_64 parse_64_register_ref (comma *> parse_64_register_ref) ;; diff --git a/asm/lib/parser/parser.ml b/asm/lib/parser/parser.ml index f9afc97a1..f35d54256 100644 --- a/asm/lib/parser/parser.ml +++ b/asm/lib/parser/parser.ml @@ -19,4 +19,4 @@ let parse_show parser show str = match parse parser str with | Result.Error e -> Format.printf "Error: %s" e | Result.Ok ast -> Format.printf "%s\n" (show ast) -;; \ No newline at end of file +;; From 30809aecd05329004de337a61322a29fe5fe157f Mon Sep 17 00:00:00 2001 From: Vadim Yakshigulov <88928096+toadharvard@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:18:28 +0000 Subject: [PATCH 10/10] Remove languages except asm --- .git-blame-ignore-revs | 0 .gitattributes | 9 - .github/CODEOWNERS | 2 - .../pull_request_template.md | 0 .github/add_comment.ml | 166 ---- .github/check_rdjson.sh | 17 - .github/dco.yml | 5 - .github/make_doc_msg.sh | 9 - .github/workflows/PR.yml | 212 ----- .github/workflows/PRformat.yml | 100 --- .github/workflows/PrPost.yml | 436 ---------- .github/workflows/master.yml | 122 --- .github/workflows/run-test.yml | 27 + .gitignore | 34 +- asm/.ocamlformat => .ocamlformat | 0 C/.gitignore | 6 - C/.ocamlformat | 4 - C/C.opam | 36 - C/Makefile | 39 - C/README.md | 14 - C/REPL.ml | 0 C/demos/demoBinarySearch.ml | 37 - C/demos/demoFact.ml | 26 - C/demos/dune | 19 - C/demos/parsingTests.t | 104 --- C/dune | 16 - C/dune-project | 33 - C/lib/ast.ml | 101 --- C/lib/dune | 10 - C/lib/parser.ml | 673 --------------- C/repl.t | 0 C/COPYING => COPYING | 0 C/COPYING.CC0 => COPYING.CC0 | 0 C/COPYING.LESSER => COPYING.LESSER | 0 CSharpExceptions/.gitignore | 6 - CSharpExceptions/.ocamlformat | 4 - CSharpExceptions/COPYING | 674 --------------- CSharpExceptions/COPYING.CC0 | 121 --- CSharpExceptions/COPYING.LESSER | 165 ---- CSharpExceptions/CSharpExceptions.opam | 35 - CSharpExceptions/Makefile | 39 - CSharpExceptions/README.md | 11 - CSharpExceptions/demos/demoParse.ml | 10 - CSharpExceptions/demos/dune | 11 - CSharpExceptions/demos/factorial.cs | 16 - CSharpExceptions/demos/parsingTests.t | 76 -- CSharpExceptions/dune-project | 34 - CSharpExceptions/lib/ast.ml | 162 ---- CSharpExceptions/lib/dune | 19 - CSharpExceptions/lib/pars_tests.ml | 368 -------- CSharpExceptions/lib/pars_tests.mli | 13 - CSharpExceptions/lib/parser.ml | 455 ---------- CSharpExceptions/lib/parser.mli | 46 - CSharpOOP/.gitignore | 6 - CSharpOOP/.ocamlformat | 4 - CSharpOOP/COPYING | 674 --------------- CSharpOOP/COPYING.CC0 | 121 --- CSharpOOP/COPYING.LESSER | 165 ---- CSharpOOP/CSharpOOP.opam | 35 - CSharpOOP/Makefile | 39 - CSharpOOP/README.md | 3 - CSharpOOP/REPL.ml | 56 -- CSharpOOP/demos/demoAO.ml | 121 --- CSharpOOP/demos/demoNO.ml | 81 -- CSharpOOP/demos/demoParse.ml | 12 - CSharpOOP/demos/demo_input.txt | 1 - CSharpOOP/demos/dune | 39 - CSharpOOP/demos/interpretTests.t | 49 -- CSharpOOP/demos/parsingTests.t | 13 - CSharpOOP/dune | 16 - CSharpOOP/dune-project | 34 - CSharpOOP/lib/Pprintast.ml | 55 -- CSharpOOP/lib/Pprintast.mli | 5 - CSharpOOP/lib/Printast.ml | 11 - CSharpOOP/lib/Printast.mli | 9 - CSharpOOP/lib/ast.mli | 15 - CSharpOOP/lib/dune | 20 - CSharpOOP/lib/interpret.ml | 31 - CSharpOOP/lib/interpret.mli | 5 - CSharpOOP/lib/lambda.ml | 119 --- CSharpOOP/lib/lambda.mli | 43 - CSharpOOP/lib/parser.ml | 65 -- CSharpOOP/lib/parser.mli | 18 - CSharpOOP/lib/tests.ml | 40 - CSharpOOP/lib/utils.ml | 30 - CSharpOOP/lib/utils.mli | 14 - CSharpOOP/repl.t | 24 - Cypher/.gitignore | 6 - Cypher/.ocamlformat | 3 - Cypher/Cypher.opam | 34 - Cypher/LICENSE | 21 - Cypher/README.md | 23 - Cypher/dune | 7 - Cypher/dune-project | 32 - Cypher/lib/ast.ml | 55 -- Cypher/lib/dune | 18 - Cypher/lib/parser.ml | 316 ------- Cypher/lib/test.ml | 74 -- DRozhkov/.gitignore | 6 - DRozhkov/.ocamlformat | 4 - DRozhkov/COPYING | 674 --------------- DRozhkov/COPYING.CC0 | 121 --- DRozhkov/COPYING.LESSER | 165 ---- DRozhkov/DONT_REMOVE_THIS_DIRECTORY.md | 3 - DRozhkov/DRozhkov.opam | 33 - DRozhkov/Makefile | 39 - DRozhkov/README.md | 96 --- DRozhkov/demos/demo_fact.ml | 13 - DRozhkov/demos/dune | 10 - DRozhkov/demos/test.t | 11 - DRozhkov/dune | 7 - DRozhkov/dune-project | 30 - DRozhkov/lib/ast.ml | 37 - DRozhkov/lib/dune | 10 - DRozhkov/lib/parser.ml | 181 ---- DSyresenkov/.gitignore | 6 - DSyresenkov/.ocamlformat | 4 - DSyresenkov/COPYING | 674 --------------- DSyresenkov/COPYING.CC0 | 121 --- DSyresenkov/COPYING.LESSER | 165 ---- DSyresenkov/DONT_REMOVE_THIS_DIRECTORY.md | 3 - DSyresenkov/DSyresenkov.opam | 35 - DSyresenkov/Makefile | 39 - DSyresenkov/README.md | 13 - DSyresenkov/demos/demoFact.ml | 8 - DSyresenkov/demos/demoFact.t | 12 - DSyresenkov/demos/dune | 10 - DSyresenkov/dune | 16 - DSyresenkov/dune-project | 34 - DSyresenkov/lib/ast.ml | 53 -- DSyresenkov/lib/dune | 20 - DSyresenkov/lib/parser.ml | 152 ---- DSyresenkov/lib/parser.mli | 9 - DSyresenkov/lib/tests.ml | 19 - FSharpActivePatterns/.gitignore | 6 - FSharpActivePatterns/.ocamlformat | 4 - FSharpActivePatterns/COPYING | 674 --------------- FSharpActivePatterns/COPYING.CC0 | 121 --- FSharpActivePatterns/COPYING.LESSER | 165 ---- .../DONT_REMOVE_THIS_DIRECTORY.md | 3 - .../FSharpActivePatterns.opam | 36 - FSharpActivePatterns/Makefile | 39 - FSharpActivePatterns/README.md | 93 -- FSharpActivePatterns/dune | 7 - FSharpActivePatterns/dune-project | 34 - FSharpActivePatterns/lib/ast.ml | 48 -- FSharpActivePatterns/lib/dune | 10 - FSharpActivePatterns/lib/parser.ml | 546 ------------ FSharpActivePatterns/lib/parser.mli | 5 - FSharpUnitsOfMeasure/.gitignore | 6 - FSharpUnitsOfMeasure/.ocamlformat | 4 - FSharpUnitsOfMeasure/COPYING | 674 --------------- FSharpUnitsOfMeasure/COPYING.CC0 | 121 --- FSharpUnitsOfMeasure/COPYING.LESSER | 165 ---- .../DONT_REMOVE_THIS_DIRECTORY.md | 3 - .../FSharpUnitsOfMeasure.opam | 35 - FSharpUnitsOfMeasure/Makefile | 39 - FSharpUnitsOfMeasure/README.md | 93 -- FSharpUnitsOfMeasure/dune | 7 - FSharpUnitsOfMeasure/dune-project | 34 - FSharpUnitsOfMeasure/lib/ast.ml | 42 - FSharpUnitsOfMeasure/lib/dune | 11 - FSharpUnitsOfMeasure/lib/parser.ml | 354 -------- Go/.gitignore | 6 - Go/.ocamlformat | 4 - Go/COPYING | 674 --------------- Go/COPYING.CC0 | 121 --- Go/COPYING.LESSER | 165 ---- Go/Lambda.opam | 35 - Go/Makefile | 39 - Go/README.md | 97 --- Go/REPL.ml | 56 -- Go/demos/demoAO.ml | 121 --- Go/demos/demoNO.ml | 81 -- Go/demos/demoParse.ml | 12 - Go/demos/demo_input.txt | 1 - Go/demos/dune | 39 - Go/demos/interpretTests.t | 49 -- Go/demos/parsingTests.t | 13 - Go/dune | 16 - Go/dune-project | 34 - Go/lib/Pprintast.ml | 55 -- Go/lib/Pprintast.mli | 5 - Go/lib/Printast.ml | 11 - Go/lib/Printast.mli | 9 - Go/lib/ast.mli | 15 - Go/lib/dune | 20 - Go/lib/interpret.ml | 31 - Go/lib/interpret.mli | 5 - Go/lib/lambda.ml | 119 --- Go/lib/lambda.mli | 43 - Go/lib/parser.ml | 65 -- Go/lib/parser.mli | 18 - Go/lib/tests.ml | 40 - Go/lib/utils.ml | 30 - Go/lib/utils.mli | 14 - Go/repl.t | 24 - Haskell/.gitignore | 7 - Haskell/.ocamlformat | 4 - Haskell/COPYING | 674 --------------- Haskell/COPYING.CC0 | 121 --- Haskell/COPYING.LESSER | 165 ---- Haskell/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Haskell/Haskell.opam | 35 - Haskell/Makefile | 39 - Haskell/README.md | 8 - Haskell/demos/dune | 9 - Haskell/demos/haskellParser.ml | 20 - Haskell/demos/haskellParser.t | 37 - Haskell/dune | 7 - Haskell/dune-project | 34 - Haskell/lib/ast.ml | 67 -- Haskell/lib/dune | 19 - Haskell/lib/parser.ml | 198 ----- Haskell/lib/tests.ml | 34 - Javascript/.gitignore | 6 - Javascript/.ocamlformat | 4 - Javascript/COPYING | 674 --------------- Javascript/COPYING.CC0 | 121 --- Javascript/COPYING.LESSER | 165 ---- Javascript/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Javascript/Lambda.opam | 35 - Javascript/Makefile | 39 - Javascript/README.md | 97 --- Javascript/REPL.ml | 56 -- Javascript/demos/demoAO.ml | 121 --- Javascript/demos/demoNO.ml | 81 -- Javascript/demos/demoParse.ml | 12 - Javascript/demos/demo_input.txt | 1 - Javascript/demos/dune | 39 - Javascript/demos/interpretTests.t | 49 -- Javascript/demos/parsingTests.t | 13 - Javascript/dune | 16 - Javascript/dune-project | 34 - Javascript/lib/Pprintast.ml | 55 -- Javascript/lib/Pprintast.mli | 5 - Javascript/lib/Printast.ml | 11 - Javascript/lib/Printast.mli | 9 - Javascript/lib/ast.mli | 15 - Javascript/lib/dune | 20 - Javascript/lib/interpret.ml | 31 - Javascript/lib/interpret.mli | 5 - Javascript/lib/lambda.ml | 119 --- Javascript/lib/lambda.mli | 43 - Javascript/lib/parser.ml | 65 -- Javascript/lib/parser.mli | 18 - Javascript/lib/tests.ml | 40 - Javascript/lib/utils.ml | 30 - Javascript/lib/utils.mli | 14 - Javascript/repl.t | 24 - LLVM_IR/.gitignore | 7 - LLVM_IR/.ocamlformat | 4 - LLVM_IR/COPYING | 674 --------------- LLVM_IR/COPYING.CC0 | 121 --- LLVM_IR/COPYING.LESSER | 165 ---- LLVM_IR/LLVM_IR.opam | 38 - LLVM_IR/LLVM_IR.opam.template | 3 - LLVM_IR/Makefile | 39 - LLVM_IR/README.md | 15 - LLVM_IR/demos/attachments/fac.ll | 36 - LLVM_IR/demos/attachments/fac_arg.ll | 225 ----- LLVM_IR/demos/attachments/simple_ssa_fail.ll | 4 - LLVM_IR/demos/attachments/sum_args.ll | 208 ----- LLVM_IR/demos/attachments/test.ll | 23 - LLVM_IR/demos/attachments/triangle_square.ll | 284 ------ LLVM_IR/demos/attachments/vec_sum_args.ll | 255 ------ LLVM_IR/demos/demoInterpret.ml | 8 - LLVM_IR/demos/demoParse.ml | 10 - LLVM_IR/demos/dune | 78 -- LLVM_IR/demos/interpretTests.t | 87 -- LLVM_IR/demos/parsingTests.t | 170 ---- LLVM_IR/dune | 7 - LLVM_IR/dune-project | 34 - LLVM_IR/lib/afterParseCheck/dune | 9 - LLVM_IR/lib/afterParseCheck/ssaCheck.ml | 157 ---- LLVM_IR/lib/afterParseCheck/ssaCheck.mli | 5 - LLVM_IR/lib/afterParseCheck/test.ml | 118 --- LLVM_IR/lib/afterParseCheck/test.mli | 3 - LLVM_IR/lib/ast/ast.ml | 204 ----- LLVM_IR/lib/ast/dune | 7 - LLVM_IR/lib/common/dune | 5 - LLVM_IR/lib/common/irInts.ml | 36 - LLVM_IR/lib/common/irInts.mli | 7 - LLVM_IR/lib/common/stateMonad.ml | 52 -- LLVM_IR/lib/common/stateMonad.mli | 17 - LLVM_IR/lib/dune | 10 - LLVM_IR/lib/interpreter/dune | 21 - .../lib/interpreter/instructions/aggregate.ml | 80 -- .../interpreter/instructions/aggregate.mli | 7 - .../lib/interpreter/instructions/binary.ml | 59 -- .../lib/interpreter/instructions/binary.mli | 7 - .../lib/interpreter/instructions/bitwise.ml | 36 - .../lib/interpreter/instructions/bitwise.mli | 7 - .../instructions/commonInterpInstructions.ml | 123 --- .../instructions/commonInterpInstructions.mli | 53 -- .../interpreter/instructions/conversion.ml | 64 -- .../interpreter/instructions/conversion.mli | 7 - LLVM_IR/lib/interpreter/instructions/dune | 20 - .../interpreter/instructions/memoryAddress.ml | 104 --- .../instructions/memoryAddress.mli | 7 - LLVM_IR/lib/interpreter/instructions/other.ml | 134 --- .../lib/interpreter/instructions/other.mli | 34 - .../interpreter/instructions/terminator.ml | 63 -- .../interpreter/instructions/terminator.mli | 7 - LLVM_IR/lib/interpreter/instructions/unary.ml | 26 - .../lib/interpreter/instructions/unary.mli | 7 - .../lib/interpreter/instructions/vector.ml | 68 -- .../lib/interpreter/instructions/vector.mli | 7 - LLVM_IR/lib/interpreter/interpreting.ml | 669 -------------- LLVM_IR/lib/interpreter/interpreting.mli | 7 - LLVM_IR/lib/interpreter/memory.ml | 57 -- LLVM_IR/lib/interpreter/memory.mli | 13 - LLVM_IR/lib/interpreter/serialisation.ml | 187 ---- LLVM_IR/lib/interpreter/serialisation.mli | 7 - LLVM_IR/lib/interpreter/state.ml | 104 --- LLVM_IR/lib/interpreter/state.mli | 138 --- LLVM_IR/lib/main.ml | 24 - LLVM_IR/lib/main.mli | 5 - LLVM_IR/lib/parser/commonParser.ml | 117 --- LLVM_IR/lib/parser/commonParser.mli | 15 - LLVM_IR/lib/parser/dune | 10 - LLVM_IR/lib/parser/instructions.ml | 699 --------------- LLVM_IR/lib/parser/instructions.mli | 6 - LLVM_IR/lib/parser/parsing.ml | 117 --- LLVM_IR/lib/parser/parsing.mli | 5 - LLVM_IR/lib/parser/types.ml | 114 --- LLVM_IR/lib/parser/types.mli | 8 - LLVM_IR/lib/parser/values.ml | 218 ----- LLVM_IR/lib/parser/values.mli | 9 - Lambda/.gitignore | 6 - Lambda/.ocamlformat | 4 - Lambda/COPYING | 674 --------------- Lambda/COPYING.CC0 | 121 --- Lambda/COPYING.LESSER | 165 ---- Lambda/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Lambda/Lambda.opam | 35 - Lambda/Makefile | 39 - Lambda/README.md | 97 --- Lambda/REPL.ml | 56 -- Lambda/demos/demoAO.ml | 121 --- Lambda/demos/demoNO.ml | 81 -- Lambda/demos/demoParse.ml | 12 - Lambda/demos/demo_input.txt | 1 - Lambda/demos/dune | 39 - Lambda/demos/interpretTests.t | 49 -- Lambda/demos/parsingTests.t | 13 - Lambda/dune | 16 - Lambda/dune-project | 34 - Lambda/lib/Pprintast.ml | 55 -- Lambda/lib/Pprintast.mli | 5 - Lambda/lib/Printast.ml | 11 - Lambda/lib/Printast.mli | 9 - Lambda/lib/ast.mli | 15 - Lambda/lib/dune | 20 - Lambda/lib/interpret.ml | 31 - Lambda/lib/interpret.mli | 5 - Lambda/lib/lambda.ml | 119 --- Lambda/lib/lambda.mli | 43 - Lambda/lib/parser.ml | 65 -- Lambda/lib/parser.mli | 18 - Lambda/lib/tests.ml | 40 - Lambda/lib/utils.ml | 30 - Lambda/lib/utils.mli | 14 - Lambda/repl.t | 24 - Lua/.gitignore | 6 - Lua/.ocamlformat | 4 - Lua/COPYING | 674 --------------- Lua/COPYING.CC0 | 121 --- Lua/COPYING.LESSER | 165 ---- Lua/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Lua/Lambda.opam | 35 - Lua/Makefile | 39 - Lua/README.md | 97 --- Lua/REPL.ml | 56 -- Lua/demos/demoAO.ml | 121 --- Lua/demos/demoNO.ml | 81 -- Lua/demos/demoParse.ml | 12 - Lua/demos/demo_input.txt | 1 - Lua/demos/dune | 39 - Lua/demos/interpretTests.t | 49 -- Lua/demos/parsingTests.t | 13 - Lua/dune | 16 - Lua/dune-project | 34 - Lua/lib/Pprintast.ml | 55 -- Lua/lib/Pprintast.mli | 5 - Lua/lib/Printast.ml | 11 - Lua/lib/Printast.mli | 9 - Lua/lib/ast.mli | 15 - Lua/lib/dune | 20 - Lua/lib/interpret.ml | 31 - Lua/lib/interpret.mli | 5 - Lua/lib/lambda.ml | 119 --- Lua/lib/lambda.mli | 43 - Lua/lib/parser.ml | 65 -- Lua/lib/parser.mli | 18 - Lua/lib/tests.ml | 40 - Lua/lib/utils.ml | 30 - Lua/lib/utils.mli | 14 - Lua/repl.t | 24 - Menhir/.gitignore | 6 - Menhir/.ocamlformat | 4 - Menhir/COPYING | 674 --------------- Menhir/COPYING.CC0 | 121 --- Menhir/COPYING.LESSER | 165 ---- Menhir/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Menhir/Lambda.opam | 35 - Menhir/Makefile | 39 - Menhir/README.md | 97 --- Menhir/REPL.ml | 56 -- Menhir/demos/demoAO.ml | 121 --- Menhir/demos/demoNO.ml | 81 -- Menhir/demos/demoParse.ml | 12 - Menhir/demos/demo_input.txt | 1 - Menhir/demos/dune | 39 - Menhir/demos/interpretTests.t | 49 -- Menhir/demos/parsingTests.t | 13 - Menhir/dune | 16 - Menhir/dune-project | 34 - Menhir/lib/Pprintast.ml | 55 -- Menhir/lib/Pprintast.mli | 5 - Menhir/lib/Printast.ml | 11 - Menhir/lib/Printast.mli | 9 - Menhir/lib/ast.mli | 15 - Menhir/lib/dune | 20 - Menhir/lib/interpret.ml | 31 - Menhir/lib/interpret.mli | 5 - Menhir/lib/lambda.ml | 119 --- Menhir/lib/lambda.mli | 43 - Menhir/lib/parser.ml | 65 -- Menhir/lib/parser.mli | 18 - Menhir/lib/tests.ml | 40 - Menhir/lib/utils.ml | 30 - Menhir/lib/utils.mli | 14 - Menhir/repl.t | 24 - OCaml+PolymorphicVariants/.gitignore | 6 - OCaml+PolymorphicVariants/.ocamlformat | 4 - OCaml+PolymorphicVariants/COPYING | 674 --------------- OCaml+PolymorphicVariants/COPYING.CC0 | 121 --- OCaml+PolymorphicVariants/COPYING.LESSER | 165 ---- OCaml+PolymorphicVariants/Makefile | 39 - .../OCaml+PolymorphicVariants.opam | 36 - OCaml+PolymorphicVariants/README.md | 97 --- OCaml+PolymorphicVariants/demos/demoParse.ml | 13 - OCaml+PolymorphicVariants/demos/demoParse.t | 14 - OCaml+PolymorphicVariants/demos/dune | 10 - OCaml+PolymorphicVariants/dune | 7 - OCaml+PolymorphicVariants/dune-project | 32 - OCaml+PolymorphicVariants/lib/ast.ml | 72 -- OCaml+PolymorphicVariants/lib/dune | 10 - OCaml+PolymorphicVariants/lib/parser.ml | 478 ---------- OCamlTyEff/.gitignore | 71 -- OCamlTyEff/.ocamlformat | 2 - OCamlTyEff/LICENSE | 21 - OCamlTyEff/OCamlTyEff.opam | 35 - OCamlTyEff/README.md | 79 -- OCamlTyEff/bin/dune | 7 - OCamlTyEff/bin/interpret.ml | 6 - OCamlTyEff/bin/interpret.t | 29 - OCamlTyEff/dune | 7 - OCamlTyEff/dune-project | 25 - OCamlTyEff/lib/ast/ast.ml | 102 --- OCamlTyEff/lib/ast/dune | 5 - OCamlTyEff/lib/parser/common.ml | 282 ------ OCamlTyEff/lib/parser/common.mli | 65 -- OCamlTyEff/lib/parser/dune | 18 - OCamlTyEff/lib/parser/expr.ml | 451 ---------- OCamlTyEff/lib/parser/expr.mli | 9 - OCamlTyEff/lib/parser/parser.ml | 11 - OCamlTyEff/lib/parser/parser.mli | 10 - OCamlTyEff/lib/parser/pattern.ml | 174 ---- OCamlTyEff/lib/parser/pattern.mli | 9 - OCamlTyEff/lib/parser/structure.ml | 24 - OCamlTyEff/lib/parser/structure.mli | 9 - OCamlTyEff/lib/parser/test.ml | 118 --- OCamlWithEffects/.gitignore | 6 - OCamlWithEffects/.ocamlformat | 4 - OCamlWithEffects/COPYING | 674 --------------- OCamlWithEffects/COPYING.CC0 | 121 --- OCamlWithEffects/COPYING.LESSER | 165 ---- .../DONT_REMOVE_THIS_DIRECTORY.md | 3 - OCamlWithEffects/Makefile | 39 - OCamlWithEffects/OCamlWithEffects.opam | 36 - OCamlWithEffects/README.md | 12 - OCamlWithEffects/demos/demoFact.ml | 10 - OCamlWithEffects/demos/demoFact.t | 12 - OCamlWithEffects/demos/dune | 10 - OCamlWithEffects/dune | 7 - OCamlWithEffects/dune-project | 35 - OCamlWithEffects/lib/ast.ml | 48 -- OCamlWithEffects/lib/dune | 9 - OCamlWithEffects/lib/parser.ml | 295 ------- OCamlWithWeakTypeVariables/.gitignore | 6 - OCamlWithWeakTypeVariables/.ocamlformat | 4 - OCamlWithWeakTypeVariables/COPYING | 674 --------------- OCamlWithWeakTypeVariables/COPYING.CC0 | 121 --- OCamlWithWeakTypeVariables/COPYING.LESSER | 165 ---- .../DONT_REMOVE_THIS_DIRECTORY.md | 3 - OCamlWithWeakTypeVariables/Lambda.opam | 35 - OCamlWithWeakTypeVariables/Makefile | 39 - OCamlWithWeakTypeVariables/README.md | 97 --- OCamlWithWeakTypeVariables/REPL.ml | 56 -- OCamlWithWeakTypeVariables/demos/demoAO.ml | 121 --- OCamlWithWeakTypeVariables/demos/demoNO.ml | 81 -- OCamlWithWeakTypeVariables/demos/demoParse.ml | 12 - .../demos/demo_input.txt | 1 - OCamlWithWeakTypeVariables/demos/dune | 39 - .../demos/interpretTests.t | 49 -- .../demos/parsingTests.t | 13 - OCamlWithWeakTypeVariables/dune | 16 - OCamlWithWeakTypeVariables/dune-project | 34 - OCamlWithWeakTypeVariables/lib/Pprintast.ml | 55 -- OCamlWithWeakTypeVariables/lib/Pprintast.mli | 5 - OCamlWithWeakTypeVariables/lib/Printast.ml | 11 - OCamlWithWeakTypeVariables/lib/Printast.mli | 9 - OCamlWithWeakTypeVariables/lib/ast.mli | 15 - OCamlWithWeakTypeVariables/lib/dune | 20 - OCamlWithWeakTypeVariables/lib/interpret.ml | 31 - OCamlWithWeakTypeVariables/lib/interpret.mli | 5 - OCamlWithWeakTypeVariables/lib/lambda.ml | 119 --- OCamlWithWeakTypeVariables/lib/lambda.mli | 43 - OCamlWithWeakTypeVariables/lib/parser.ml | 65 -- OCamlWithWeakTypeVariables/lib/parser.mli | 18 - OCamlWithWeakTypeVariables/lib/tests.ml | 40 - OCamlWithWeakTypeVariables/lib/utils.ml | 30 - OCamlWithWeakTypeVariables/lib/utils.mli | 14 - OCamlWithWeakTypeVariables/repl.t | 24 - OCaml_BidirectionalRecords/.gitignore | 8 - OCaml_BidirectionalRecords/.ocamlformat | 4 - OCaml_BidirectionalRecords/COPYING | 674 --------------- OCaml_BidirectionalRecords/COPYING.CC0 | 121 --- OCaml_BidirectionalRecords/COPYING.LESSER | 165 ---- OCaml_BidirectionalRecords/Makefile | 39 - .../OCaml_BidirectionalRecords.opam | 35 - OCaml_BidirectionalRecords/README.md | 97 --- OCaml_BidirectionalRecords/demos/dune | 0 OCaml_BidirectionalRecords/dune | 7 - OCaml_BidirectionalRecords/dune-project | 34 - OCaml_BidirectionalRecords/lib/ast.ml | 83 -- OCaml_BidirectionalRecords/lib/dune | 10 - OCaml_BidirectionalRecords/lib/parser.ml | 166 ---- OCaml_BidirectionalRecords/lib/tests.ml | 36 - OCaml_ExtensibleVariantTypes/.gitignore | 6 - OCaml_ExtensibleVariantTypes/.ocamlformat | 4 - OCaml_ExtensibleVariantTypes/COPYING | 674 --------------- OCaml_ExtensibleVariantTypes/COPYING.CC0 | 121 --- OCaml_ExtensibleVariantTypes/COPYING.LESSER | 165 ---- OCaml_ExtensibleVariantTypes/Makefile | 39 - .../OCaml_ExtensibleVariantTypes.opam | 35 - OCaml_ExtensibleVariantTypes/README.md | 97 --- OCaml_ExtensibleVariantTypes/REPL.ml | 8 - .../demos/demoParse.ml | 8 - .../demos/demo_input.txt | 1 - OCaml_ExtensibleVariantTypes/demos/dune | 14 - .../demos/parsingTests.t | 16 - OCaml_ExtensibleVariantTypes/dune | 16 - OCaml_ExtensibleVariantTypes/dune-project | 31 - OCaml_ExtensibleVariantTypes/lib/ast.ml | 68 -- OCaml_ExtensibleVariantTypes/lib/dune | 20 - OCaml_ExtensibleVariantTypes/lib/parser.ml | 297 ------- OCaml_ExtensibleVariantTypes/lib/tests.ml | 172 ---- OCaml_ExtensibleVariantTypes/repl.t | 5 - Ocaml+ADT/.gitignore | 8 - Ocaml+ADT/.ocamlformat | 4 - Ocaml+ADT/COPYING | 674 --------------- Ocaml+ADT/COPYING.CC0 | 121 --- Ocaml+ADT/COPYING.LESSER | 165 ---- Ocaml+ADT/Makefile | 39 - Ocaml+ADT/Ocaml+ADT.opam | 33 - Ocaml+ADT/README.md | 97 --- Ocaml+ADT/demos/demoFact.ml | 11 - Ocaml+ADT/demos/demoFact.t | 12 - Ocaml+ADT/demos/dune | 10 - Ocaml+ADT/dune | 7 - Ocaml+ADT/dune-project | 31 - Ocaml+ADT/lib/ast.ml | 118 --- Ocaml+ADT/lib/dune | 10 - Ocaml+ADT/lib/parser.ml | 526 ----------- Ocaml+printf/.gitignore | 7 - Ocaml+printf/.ocamlformat | 4 - Ocaml+printf/COPYING | 674 --------------- Ocaml+printf/COPYING.CC0 | 121 --- Ocaml+printf/COPYING.LESSER | 165 ---- Ocaml+printf/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Ocaml+printf/Makefile | 39 - Ocaml+printf/Ocaml+printf.opam | 35 - Ocaml+printf/README.md | 97 --- Ocaml+printf/demos/demoInfer.ml | 16 - Ocaml+printf/demos/demoInfer.t | 42 - Ocaml+printf/demos/demoInterpreter.ml | 36 - Ocaml+printf/demos/demoInterpreter.t | 103 --- Ocaml+printf/demos/demoParse.ml | 12 - Ocaml+printf/demos/demoParse.t | 27 - Ocaml+printf/demos/dune | 26 - Ocaml+printf/dune-project | 34 - Ocaml+printf/lib/ast.ml | 87 -- Ocaml+printf/lib/dune | 27 - Ocaml+printf/lib/inferencer.ml | 689 --------------- Ocaml+printf/lib/inferencer.mli | 27 - Ocaml+printf/lib/interpreter.ml | 451 ---------- Ocaml+printf/lib/interpreter.mli | 38 - Ocaml+printf/lib/parser.ml | 434 ---------- Ocaml+printf/lib/parser.mli | 9 - Ocaml+printf/lib/pprint.ml | 85 -- Ocaml+printf/lib/pprint.mli | 7 - Ocaml+printf/lib/tests/infer_tests.ml | 316 ------- Ocaml+printf/lib/tests/infer_tests.mli | 3 - Ocaml+printf/lib/tests/interpret_tests.ml | 183 ---- Ocaml+printf/lib/tests/interpret_tests.mli | 3 - Ocaml+printf/lib/tests/parser_tests.ml | 317 ------- Ocaml+printf/lib/tests/parser_tests.mli | 3 - Ocaml+printf/lib/typedtree.ml | 26 - Ocaml+printf/lib/typedtree.mli | 40 - OcamlOOP/.gitignore | 6 - OcamlOOP/.ocamlformat | 4 - OcamlOOP/COPYING | 674 --------------- OcamlOOP/COPYING.CC0 | 121 --- OcamlOOP/COPYING.LESSER | 165 ---- OcamlOOP/DONT_REMOVE_THIS_DIRECTORY.md | 3 - OcamlOOP/Makefile | 39 - OcamlOOP/OcamlOOP.opam | 36 - OcamlOOP/README.md | 92 -- OcamlOOP/demos/demo.ml | 12 - OcamlOOP/demos/demo_fact.ml | 13 - OcamlOOP/demos/demo_obj.ml | 32 - OcamlOOP/demos/demo_obj1.ml | 24 - OcamlOOP/demos/dune | 53 -- OcamlOOP/demos/test.t | 79 -- OcamlOOP/dune | 7 - OcamlOOP/dune-project | 34 - OcamlOOP/lib/ast.ml | 96 --- OcamlOOP/lib/dune | 10 - OcamlOOP/lib/parser.ml | 250 ------ Parallel_execution_simulation/.gitignore | 6 - Parallel_execution_simulation/.ocamlformat | 4 - Parallel_execution_simulation/COPYING | 674 --------------- Parallel_execution_simulation/COPYING.CC0 | 121 --- Parallel_execution_simulation/COPYING.LESSER | 165 ---- Parallel_execution_simulation/Makefile | 39 - .../Parallel_execution_simulation.opam | 35 - Parallel_execution_simulation/README.md | 19 - .../demos/demoParser.ml | 7 - Parallel_execution_simulation/demos/dune | 7 - Parallel_execution_simulation/dune | 7 - Parallel_execution_simulation/dune-project | 30 - Parallel_execution_simulation/lib/ast.ml | 19 - Parallel_execution_simulation/lib/dune | 15 - Parallel_execution_simulation/lib/parser.ml | 131 --- Parallel_execution_simulation/lib/parser.mli | 5 - PrologDatalog/.gitignore | 6 - PrologDatalog/.ocamlformat | 4 - PrologDatalog/COPYING | 674 --------------- PrologDatalog/COPYING.CC0 | 121 --- PrologDatalog/COPYING.LESSER | 165 ---- PrologDatalog/Makefile | 39 - PrologDatalog/PrologDatalog.opam | 36 - PrologDatalog/README.md | 95 -- PrologDatalog/dune | 7 - PrologDatalog/dune-project | 35 - PrologDatalog/lib/ast.ml | 33 - PrologDatalog/lib/dune | 10 - PrologDatalog/lib/parser.ml | 245 ------ PrologDatalog/lib/parser.mli | 19 - Python/.gitignore | 6 - Python/.ocamlformat | 4 - Python/COPYING | 674 --------------- Python/COPYING.CC0 | 121 --- Python/COPYING.LESSER | 165 ---- Python/DONT_REMOVE_THIS_DIRECTORY.md | 3 - Python/Makefile | 39 - Python/Python.opam | 35 - Python/README.md | 93 -- Python/REPL.ml | 57 -- Python/demos/demo_fact.ml | 18 - Python/demos/dune | 25 - Python/demos/interpreter_test.ml | 28 - Python/demos/test.t | 19 - Python/dune | 16 - Python/dune-project | 35 - Python/lib/ast.ml | 58 -- Python/lib/dune | 10 - Python/lib/interpreter.ml | 333 ------- Python/lib/interpreter.mli | 83 -- Python/lib/parser.ml | 370 -------- Python/lib/parser.mli | 160 ---- Python/lib/tests.ml | 226 ----- Python/lib/tests.mli | 3 - Python/repl.t | 0 README.md | 88 +- Refal5/.gitignore | 6 - Refal5/.ocamlformat | 4 - Refal5/COPYING | 674 --------------- Refal5/COPYING.CC0 | 121 --- Refal5/COPYING.LESSER | 165 ---- Refal5/Lambda.opam | 35 - Refal5/Makefile | 39 - Refal5/README.md | 97 --- Refal5/REPL.ml | 56 -- Refal5/demos/demoAO.ml | 121 --- Refal5/demos/demoNO.ml | 81 -- Refal5/demos/demoParse.ml | 12 - Refal5/demos/demo_input.txt | 1 - Refal5/demos/dune | 39 - Refal5/demos/interpretTests.t | 49 -- Refal5/demos/parsingTests.t | 13 - Refal5/dune | 16 - Refal5/dune-project | 34 - Refal5/lib/Pprintast.ml | 55 -- Refal5/lib/Pprintast.mli | 5 - Refal5/lib/Printast.ml | 11 - Refal5/lib/Printast.mli | 9 - Refal5/lib/ast.mli | 15 - Refal5/lib/dune | 20 - Refal5/lib/interpret.ml | 31 - Refal5/lib/interpret.mli | 5 - Refal5/lib/lambda.ml | 119 --- Refal5/lib/lambda.mli | 43 - Refal5/lib/parser.ml | 65 -- Refal5/lib/parser.mli | 18 - Refal5/lib/tests.ml | 40 - Refal5/lib/utils.ml | 30 - Refal5/lib/utils.mli | 14 - Refal5/repl.t | 24 - Ruby/.gitignore | 6 - Ruby/.ocamlformat | 4 - Ruby/COPYING | 674 --------------- Ruby/COPYING.CC0 | 121 --- Ruby/COPYING.LESSER | 165 ---- Ruby/Makefile | 39 - Ruby/README.md | 12 - Ruby/Ruby.opam | 36 - Ruby/demos/demoParser.ml | 7 - Ruby/demos/demoParser.t | 21 - Ruby/demos/dune | 10 - Ruby/dune | 8 - Ruby/dune-project | 35 - Ruby/examples/facfib.rb | 17 - Ruby/lib/ast.ml | 39 - Ruby/lib/dune | 20 - Ruby/lib/interpret.ml | 0 Ruby/lib/interpret.mli | 0 Ruby/lib/parser.ml | 221 ----- Ruby/lib/tests.ml | 0 Ruby/lib/utils.ml | 0 Ruby/lib/utils.mli | 0 SchemeDelimCC/.gitignore | 6 - SchemeDelimCC/.ocamlformat | 4 - SchemeDelimCC/COPYING | 674 --------------- SchemeDelimCC/COPYING.CC0 | 121 --- SchemeDelimCC/COPYING.LESSER | 165 ---- SchemeDelimCC/DONT_REMOVE_THIS_DIRECTORY.md | 3 - SchemeDelimCC/Lambda.opam | 35 - SchemeDelimCC/Makefile | 39 - SchemeDelimCC/README.md | 96 --- SchemeDelimCC/REPL.ml | 56 -- SchemeDelimCC/demos/demoAO.ml | 121 --- SchemeDelimCC/demos/demoNO.ml | 81 -- SchemeDelimCC/demos/demoParse.ml | 12 - SchemeDelimCC/demos/demo_input.txt | 1 - SchemeDelimCC/demos/dune | 39 - SchemeDelimCC/demos/interpretTests.t | 49 -- SchemeDelimCC/demos/parsingTests.t | 13 - SchemeDelimCC/dune | 16 - SchemeDelimCC/dune-project | 34 - SchemeDelimCC/lib/Pprintast.ml | 55 -- SchemeDelimCC/lib/Pprintast.mli | 5 - SchemeDelimCC/lib/Printast.ml | 11 - SchemeDelimCC/lib/Printast.mli | 9 - SchemeDelimCC/lib/ast.mli | 15 - SchemeDelimCC/lib/dune | 20 - SchemeDelimCC/lib/interpret.ml | 31 - SchemeDelimCC/lib/interpret.mli | 5 - SchemeDelimCC/lib/lambda.ml | 119 --- SchemeDelimCC/lib/lambda.mli | 43 - SchemeDelimCC/lib/parser.ml | 65 -- SchemeDelimCC/lib/parser.mli | 18 - SchemeDelimCC/lib/tests.ml | 40 - SchemeDelimCC/lib/utils.ml | 30 - SchemeDelimCC/lib/utils.mli | 14 - SchemeDelimCC/repl.t | 24 - asm/asm.opam => asm.opam | 0 asm/.gitignore | 31 - asm/COPYING | 674 --------------- asm/COPYING.CC0 | 121 --- asm/COPYING.LESSER | 165 ---- asm/README.md | 13 - asm/dune | 7 - {asm/bin => bin}/demoInterpreter.ml | 0 {asm/bin => bin}/demoInterpreter.t | 0 {asm/bin => bin}/demoParser.ml | 0 {asm/bin => bin}/demoParser.t | 0 {asm/bin => bin}/dune | 0 {asm/bin => bin}/sources/fib.asm | 0 {asm/bin => bin}/sources/matrix.asm | 0 {asm/bin => bin}/sources/scalar.asm | 0 build_latest.sh | 82 -- detect_latest.sh | 36 - detect_latest_pr.ml | 124 --- detect_latest_pr.sh | 36 - asm/devbox.json => devbox.json | 0 asm/devbox.lock => devbox.lock | 0 CSharpExceptions/dune => dune | 0 asm/dune-project => dune-project | 0 exam.md | 51 -- find_clones.py | 27 - {asm/lib => lib}/ast/ast.ml | 0 {asm/lib => lib}/ast/dune | 0 {asm/lib => lib}/interpreter/containers.ml | 0 {asm/lib => lib}/interpreter/containers.mli | 0 {asm/lib => lib}/interpreter/dune | 0 {asm/lib => lib}/interpreter/interpreter.ml | 0 {asm/lib => lib}/interpreter/interpreter.mli | 0 {asm/lib => lib}/interpreter/state.ml | 0 {asm/lib => lib}/interpreter/state.mli | 0 {asm/lib => lib}/parser/common.ml | 0 {asm/lib => lib}/parser/common.mli | 0 {asm/lib => lib}/parser/directive.ml | 0 {asm/lib => lib}/parser/directive.mli | 0 {asm/lib => lib}/parser/dune | 0 {asm/lib => lib}/parser/immediate.ml | 0 {asm/lib => lib}/parser/immediate.mli | 0 {asm/lib => lib}/parser/operand.ml | 0 {asm/lib => lib}/parser/operand.mli | 0 {asm/lib => lib}/parser/parser.ml | 0 {asm/lib => lib}/parser/parser.mli | 0 {asm/lib => lib}/parser/register.ml | 0 {asm/lib => lib}/parser/register.mli | 0 {asm/lib => lib}/parser/statement.ml | 0 {asm/lib => lib}/parser/statement.mli | 0 lint_filesystem.py | 49 -- mini-SQL/.gitignore | 6 - mini-SQL/.ocamlformat | 4 - mini-SQL/COPYING | 674 --------------- mini-SQL/COPYING.CC0 | 121 --- mini-SQL/COPYING.LESSER | 165 ---- mini-SQL/Makefile | 39 - mini-SQL/README.md | 1 - mini-SQL/REPL.ml | 56 -- mini-SQL/demos/demoAO.ml | 121 --- mini-SQL/demos/demoNO.ml | 81 -- mini-SQL/demos/demoParse.ml | 12 - mini-SQL/demos/demo_input.txt | 1 - mini-SQL/demos/dune | 36 - mini-SQL/demos/parsingTests.t | 23 - mini-SQL/dune | 16 - mini-SQL/dune-project | 32 - mini-SQL/lib/ast.ml | 46 - mini-SQL/lib/dune | 8 - mini-SQL/lib/parser.ml | 217 ----- mini-SQL/lib/test.ml | 81 -- mini-SQL/mini-SQL.opam | 36 - named and optional arguments/.gitignore | 6 - named and optional arguments/.ocamlformat | 4 - named and optional arguments/COPYING | 674 --------------- named and optional arguments/COPYING.CC0 | 121 --- named and optional arguments/COPYING.LESSER | 165 ---- .../DONT_REMOVE_THIS_DIRECTORY.md | 3 - named and optional arguments/Lambda.opam | 35 - named and optional arguments/Makefile | 39 - named and optional arguments/README.md | 97 --- named and optional arguments/REPL.ml | 56 -- named and optional arguments/demos/demoAO.ml | 121 --- named and optional arguments/demos/demoNO.ml | 81 -- .../demos/demoParse.ml | 12 - .../demos/demo_input.txt | 1 - named and optional arguments/demos/dune | 39 - .../demos/interpretTests.t | 49 -- .../demos/parsingTests.t | 13 - named and optional arguments/dune | 16 - named and optional arguments/dune-project | 34 - named and optional arguments/lib/Pprintast.ml | 55 -- .../lib/Pprintast.mli | 5 - named and optional arguments/lib/Printast.ml | 11 - named and optional arguments/lib/Printast.mli | 9 - named and optional arguments/lib/ast.mli | 15 - named and optional arguments/lib/dune | 20 - named and optional arguments/lib/interpret.ml | 31 - .../lib/interpret.mli | 5 - named and optional arguments/lib/lambda.ml | 119 --- named and optional arguments/lib/lambda.mli | 43 - named and optional arguments/lib/parser.ml | 65 -- named and optional arguments/lib/parser.mli | 18 - named and optional arguments/lib/tests.ml | 40 - named and optional arguments/lib/utils.ml | 30 - named and optional arguments/lib/utils.mli | 14 - named and optional arguments/repl.t | 24 - tasks.md | 816 ------------------ 886 files changed, 65 insertions(+), 66726 deletions(-) delete mode 100644 .git-blame-ignore-revs delete mode 100644 .gitattributes delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md delete mode 100644 .github/add_comment.ml delete mode 100755 .github/check_rdjson.sh delete mode 100644 .github/dco.yml delete mode 100755 .github/make_doc_msg.sh delete mode 100644 .github/workflows/PR.yml delete mode 100644 .github/workflows/PRformat.yml delete mode 100644 .github/workflows/PrPost.yml delete mode 100644 .github/workflows/master.yml create mode 100644 .github/workflows/run-test.yml rename asm/.ocamlformat => .ocamlformat (100%) delete mode 100644 C/.gitignore delete mode 100644 C/.ocamlformat delete mode 100644 C/C.opam delete mode 100644 C/Makefile delete mode 100644 C/README.md delete mode 100644 C/REPL.ml delete mode 100644 C/demos/demoBinarySearch.ml delete mode 100644 C/demos/demoFact.ml delete mode 100644 C/demos/dune delete mode 100644 C/demos/parsingTests.t delete mode 100644 C/dune delete mode 100644 C/dune-project delete mode 100644 C/lib/ast.ml delete mode 100644 C/lib/dune delete mode 100644 C/lib/parser.ml delete mode 100644 C/repl.t rename C/COPYING => COPYING (100%) rename C/COPYING.CC0 => COPYING.CC0 (100%) rename C/COPYING.LESSER => COPYING.LESSER (100%) delete mode 100644 CSharpExceptions/.gitignore delete mode 100644 CSharpExceptions/.ocamlformat delete mode 100644 CSharpExceptions/COPYING delete mode 100644 CSharpExceptions/COPYING.CC0 delete mode 100644 CSharpExceptions/COPYING.LESSER delete mode 100644 CSharpExceptions/CSharpExceptions.opam delete mode 100644 CSharpExceptions/Makefile delete mode 100644 CSharpExceptions/README.md delete mode 100644 CSharpExceptions/demos/demoParse.ml delete mode 100644 CSharpExceptions/demos/dune delete mode 100644 CSharpExceptions/demos/factorial.cs delete mode 100644 CSharpExceptions/demos/parsingTests.t delete mode 100644 CSharpExceptions/dune-project delete mode 100644 CSharpExceptions/lib/ast.ml delete mode 100644 CSharpExceptions/lib/dune delete mode 100644 CSharpExceptions/lib/pars_tests.ml delete mode 100644 CSharpExceptions/lib/pars_tests.mli delete mode 100644 CSharpExceptions/lib/parser.ml delete mode 100644 CSharpExceptions/lib/parser.mli delete mode 100644 CSharpOOP/.gitignore delete mode 100644 CSharpOOP/.ocamlformat delete mode 100644 CSharpOOP/COPYING delete mode 100644 CSharpOOP/COPYING.CC0 delete mode 100644 CSharpOOP/COPYING.LESSER delete mode 100644 CSharpOOP/CSharpOOP.opam delete mode 100644 CSharpOOP/Makefile delete mode 100644 CSharpOOP/README.md delete mode 100644 CSharpOOP/REPL.ml delete mode 100644 CSharpOOP/demos/demoAO.ml delete mode 100644 CSharpOOP/demos/demoNO.ml delete mode 100644 CSharpOOP/demos/demoParse.ml delete mode 100644 CSharpOOP/demos/demo_input.txt delete mode 100644 CSharpOOP/demos/dune delete mode 100644 CSharpOOP/demos/interpretTests.t delete mode 100644 CSharpOOP/demos/parsingTests.t delete mode 100644 CSharpOOP/dune delete mode 100644 CSharpOOP/dune-project delete mode 100644 CSharpOOP/lib/Pprintast.ml delete mode 100644 CSharpOOP/lib/Pprintast.mli delete mode 100644 CSharpOOP/lib/Printast.ml delete mode 100644 CSharpOOP/lib/Printast.mli delete mode 100644 CSharpOOP/lib/ast.mli delete mode 100644 CSharpOOP/lib/dune delete mode 100644 CSharpOOP/lib/interpret.ml delete mode 100644 CSharpOOP/lib/interpret.mli delete mode 100644 CSharpOOP/lib/lambda.ml delete mode 100644 CSharpOOP/lib/lambda.mli delete mode 100644 CSharpOOP/lib/parser.ml delete mode 100644 CSharpOOP/lib/parser.mli delete mode 100644 CSharpOOP/lib/tests.ml delete mode 100644 CSharpOOP/lib/utils.ml delete mode 100644 CSharpOOP/lib/utils.mli delete mode 100644 CSharpOOP/repl.t delete mode 100644 Cypher/.gitignore delete mode 100644 Cypher/.ocamlformat delete mode 100644 Cypher/Cypher.opam delete mode 100644 Cypher/LICENSE delete mode 100644 Cypher/README.md delete mode 100644 Cypher/dune delete mode 100644 Cypher/dune-project delete mode 100644 Cypher/lib/ast.ml delete mode 100644 Cypher/lib/dune delete mode 100644 Cypher/lib/parser.ml delete mode 100644 Cypher/lib/test.ml delete mode 100644 DRozhkov/.gitignore delete mode 100644 DRozhkov/.ocamlformat delete mode 100644 DRozhkov/COPYING delete mode 100644 DRozhkov/COPYING.CC0 delete mode 100644 DRozhkov/COPYING.LESSER delete mode 100644 DRozhkov/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 DRozhkov/DRozhkov.opam delete mode 100644 DRozhkov/Makefile delete mode 100644 DRozhkov/README.md delete mode 100644 DRozhkov/demos/demo_fact.ml delete mode 100644 DRozhkov/demos/dune delete mode 100644 DRozhkov/demos/test.t delete mode 100644 DRozhkov/dune delete mode 100644 DRozhkov/dune-project delete mode 100644 DRozhkov/lib/ast.ml delete mode 100644 DRozhkov/lib/dune delete mode 100644 DRozhkov/lib/parser.ml delete mode 100644 DSyresenkov/.gitignore delete mode 100644 DSyresenkov/.ocamlformat delete mode 100644 DSyresenkov/COPYING delete mode 100644 DSyresenkov/COPYING.CC0 delete mode 100644 DSyresenkov/COPYING.LESSER delete mode 100644 DSyresenkov/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 DSyresenkov/DSyresenkov.opam delete mode 100644 DSyresenkov/Makefile delete mode 100644 DSyresenkov/README.md delete mode 100644 DSyresenkov/demos/demoFact.ml delete mode 100644 DSyresenkov/demos/demoFact.t delete mode 100644 DSyresenkov/demos/dune delete mode 100644 DSyresenkov/dune delete mode 100644 DSyresenkov/dune-project delete mode 100644 DSyresenkov/lib/ast.ml delete mode 100644 DSyresenkov/lib/dune delete mode 100644 DSyresenkov/lib/parser.ml delete mode 100644 DSyresenkov/lib/parser.mli delete mode 100644 DSyresenkov/lib/tests.ml delete mode 100644 FSharpActivePatterns/.gitignore delete mode 100644 FSharpActivePatterns/.ocamlformat delete mode 100644 FSharpActivePatterns/COPYING delete mode 100644 FSharpActivePatterns/COPYING.CC0 delete mode 100644 FSharpActivePatterns/COPYING.LESSER delete mode 100644 FSharpActivePatterns/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 FSharpActivePatterns/FSharpActivePatterns.opam delete mode 100644 FSharpActivePatterns/Makefile delete mode 100644 FSharpActivePatterns/README.md delete mode 100644 FSharpActivePatterns/dune delete mode 100644 FSharpActivePatterns/dune-project delete mode 100644 FSharpActivePatterns/lib/ast.ml delete mode 100644 FSharpActivePatterns/lib/dune delete mode 100644 FSharpActivePatterns/lib/parser.ml delete mode 100644 FSharpActivePatterns/lib/parser.mli delete mode 100644 FSharpUnitsOfMeasure/.gitignore delete mode 100644 FSharpUnitsOfMeasure/.ocamlformat delete mode 100644 FSharpUnitsOfMeasure/COPYING delete mode 100644 FSharpUnitsOfMeasure/COPYING.CC0 delete mode 100644 FSharpUnitsOfMeasure/COPYING.LESSER delete mode 100644 FSharpUnitsOfMeasure/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 FSharpUnitsOfMeasure/FSharpUnitsOfMeasure.opam delete mode 100644 FSharpUnitsOfMeasure/Makefile delete mode 100644 FSharpUnitsOfMeasure/README.md delete mode 100644 FSharpUnitsOfMeasure/dune delete mode 100644 FSharpUnitsOfMeasure/dune-project delete mode 100644 FSharpUnitsOfMeasure/lib/ast.ml delete mode 100644 FSharpUnitsOfMeasure/lib/dune delete mode 100644 FSharpUnitsOfMeasure/lib/parser.ml delete mode 100644 Go/.gitignore delete mode 100644 Go/.ocamlformat delete mode 100644 Go/COPYING delete mode 100644 Go/COPYING.CC0 delete mode 100644 Go/COPYING.LESSER delete mode 100644 Go/Lambda.opam delete mode 100644 Go/Makefile delete mode 100644 Go/README.md delete mode 100644 Go/REPL.ml delete mode 100644 Go/demos/demoAO.ml delete mode 100644 Go/demos/demoNO.ml delete mode 100644 Go/demos/demoParse.ml delete mode 100644 Go/demos/demo_input.txt delete mode 100644 Go/demos/dune delete mode 100644 Go/demos/interpretTests.t delete mode 100644 Go/demos/parsingTests.t delete mode 100644 Go/dune delete mode 100644 Go/dune-project delete mode 100644 Go/lib/Pprintast.ml delete mode 100644 Go/lib/Pprintast.mli delete mode 100644 Go/lib/Printast.ml delete mode 100644 Go/lib/Printast.mli delete mode 100644 Go/lib/ast.mli delete mode 100644 Go/lib/dune delete mode 100644 Go/lib/interpret.ml delete mode 100644 Go/lib/interpret.mli delete mode 100644 Go/lib/lambda.ml delete mode 100644 Go/lib/lambda.mli delete mode 100644 Go/lib/parser.ml delete mode 100644 Go/lib/parser.mli delete mode 100644 Go/lib/tests.ml delete mode 100644 Go/lib/utils.ml delete mode 100644 Go/lib/utils.mli delete mode 100644 Go/repl.t delete mode 100644 Haskell/.gitignore delete mode 100644 Haskell/.ocamlformat delete mode 100644 Haskell/COPYING delete mode 100644 Haskell/COPYING.CC0 delete mode 100644 Haskell/COPYING.LESSER delete mode 100644 Haskell/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Haskell/Haskell.opam delete mode 100644 Haskell/Makefile delete mode 100644 Haskell/README.md delete mode 100644 Haskell/demos/dune delete mode 100644 Haskell/demos/haskellParser.ml delete mode 100644 Haskell/demos/haskellParser.t delete mode 100644 Haskell/dune delete mode 100644 Haskell/dune-project delete mode 100644 Haskell/lib/ast.ml delete mode 100644 Haskell/lib/dune delete mode 100644 Haskell/lib/parser.ml delete mode 100644 Haskell/lib/tests.ml delete mode 100644 Javascript/.gitignore delete mode 100644 Javascript/.ocamlformat delete mode 100644 Javascript/COPYING delete mode 100644 Javascript/COPYING.CC0 delete mode 100644 Javascript/COPYING.LESSER delete mode 100644 Javascript/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Javascript/Lambda.opam delete mode 100644 Javascript/Makefile delete mode 100644 Javascript/README.md delete mode 100644 Javascript/REPL.ml delete mode 100644 Javascript/demos/demoAO.ml delete mode 100644 Javascript/demos/demoNO.ml delete mode 100644 Javascript/demos/demoParse.ml delete mode 100644 Javascript/demos/demo_input.txt delete mode 100644 Javascript/demos/dune delete mode 100644 Javascript/demos/interpretTests.t delete mode 100644 Javascript/demos/parsingTests.t delete mode 100644 Javascript/dune delete mode 100644 Javascript/dune-project delete mode 100644 Javascript/lib/Pprintast.ml delete mode 100644 Javascript/lib/Pprintast.mli delete mode 100644 Javascript/lib/Printast.ml delete mode 100644 Javascript/lib/Printast.mli delete mode 100644 Javascript/lib/ast.mli delete mode 100644 Javascript/lib/dune delete mode 100644 Javascript/lib/interpret.ml delete mode 100644 Javascript/lib/interpret.mli delete mode 100644 Javascript/lib/lambda.ml delete mode 100644 Javascript/lib/lambda.mli delete mode 100644 Javascript/lib/parser.ml delete mode 100644 Javascript/lib/parser.mli delete mode 100644 Javascript/lib/tests.ml delete mode 100644 Javascript/lib/utils.ml delete mode 100644 Javascript/lib/utils.mli delete mode 100644 Javascript/repl.t delete mode 100644 LLVM_IR/.gitignore delete mode 100644 LLVM_IR/.ocamlformat delete mode 100644 LLVM_IR/COPYING delete mode 100644 LLVM_IR/COPYING.CC0 delete mode 100644 LLVM_IR/COPYING.LESSER delete mode 100644 LLVM_IR/LLVM_IR.opam delete mode 100644 LLVM_IR/LLVM_IR.opam.template delete mode 100644 LLVM_IR/Makefile delete mode 100644 LLVM_IR/README.md delete mode 100644 LLVM_IR/demos/attachments/fac.ll delete mode 100644 LLVM_IR/demos/attachments/fac_arg.ll delete mode 100644 LLVM_IR/demos/attachments/simple_ssa_fail.ll delete mode 100644 LLVM_IR/demos/attachments/sum_args.ll delete mode 100644 LLVM_IR/demos/attachments/test.ll delete mode 100644 LLVM_IR/demos/attachments/triangle_square.ll delete mode 100644 LLVM_IR/demos/attachments/vec_sum_args.ll delete mode 100644 LLVM_IR/demos/demoInterpret.ml delete mode 100644 LLVM_IR/demos/demoParse.ml delete mode 100644 LLVM_IR/demos/dune delete mode 100644 LLVM_IR/demos/interpretTests.t delete mode 100644 LLVM_IR/demos/parsingTests.t delete mode 100644 LLVM_IR/dune delete mode 100644 LLVM_IR/dune-project delete mode 100644 LLVM_IR/lib/afterParseCheck/dune delete mode 100644 LLVM_IR/lib/afterParseCheck/ssaCheck.ml delete mode 100644 LLVM_IR/lib/afterParseCheck/ssaCheck.mli delete mode 100644 LLVM_IR/lib/afterParseCheck/test.ml delete mode 100644 LLVM_IR/lib/afterParseCheck/test.mli delete mode 100644 LLVM_IR/lib/ast/ast.ml delete mode 100644 LLVM_IR/lib/ast/dune delete mode 100644 LLVM_IR/lib/common/dune delete mode 100644 LLVM_IR/lib/common/irInts.ml delete mode 100644 LLVM_IR/lib/common/irInts.mli delete mode 100644 LLVM_IR/lib/common/stateMonad.ml delete mode 100644 LLVM_IR/lib/common/stateMonad.mli delete mode 100644 LLVM_IR/lib/dune delete mode 100644 LLVM_IR/lib/interpreter/dune delete mode 100644 LLVM_IR/lib/interpreter/instructions/aggregate.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/aggregate.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/binary.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/binary.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/bitwise.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/bitwise.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/conversion.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/conversion.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/dune delete mode 100644 LLVM_IR/lib/interpreter/instructions/memoryAddress.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/memoryAddress.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/other.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/other.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/terminator.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/terminator.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/unary.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/unary.mli delete mode 100644 LLVM_IR/lib/interpreter/instructions/vector.ml delete mode 100644 LLVM_IR/lib/interpreter/instructions/vector.mli delete mode 100644 LLVM_IR/lib/interpreter/interpreting.ml delete mode 100644 LLVM_IR/lib/interpreter/interpreting.mli delete mode 100644 LLVM_IR/lib/interpreter/memory.ml delete mode 100644 LLVM_IR/lib/interpreter/memory.mli delete mode 100644 LLVM_IR/lib/interpreter/serialisation.ml delete mode 100644 LLVM_IR/lib/interpreter/serialisation.mli delete mode 100644 LLVM_IR/lib/interpreter/state.ml delete mode 100644 LLVM_IR/lib/interpreter/state.mli delete mode 100644 LLVM_IR/lib/main.ml delete mode 100644 LLVM_IR/lib/main.mli delete mode 100644 LLVM_IR/lib/parser/commonParser.ml delete mode 100644 LLVM_IR/lib/parser/commonParser.mli delete mode 100644 LLVM_IR/lib/parser/dune delete mode 100644 LLVM_IR/lib/parser/instructions.ml delete mode 100644 LLVM_IR/lib/parser/instructions.mli delete mode 100644 LLVM_IR/lib/parser/parsing.ml delete mode 100644 LLVM_IR/lib/parser/parsing.mli delete mode 100644 LLVM_IR/lib/parser/types.ml delete mode 100644 LLVM_IR/lib/parser/types.mli delete mode 100644 LLVM_IR/lib/parser/values.ml delete mode 100644 LLVM_IR/lib/parser/values.mli delete mode 100644 Lambda/.gitignore delete mode 100644 Lambda/.ocamlformat delete mode 100644 Lambda/COPYING delete mode 100644 Lambda/COPYING.CC0 delete mode 100644 Lambda/COPYING.LESSER delete mode 100644 Lambda/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Lambda/Lambda.opam delete mode 100644 Lambda/Makefile delete mode 100644 Lambda/README.md delete mode 100644 Lambda/REPL.ml delete mode 100644 Lambda/demos/demoAO.ml delete mode 100644 Lambda/demos/demoNO.ml delete mode 100644 Lambda/demos/demoParse.ml delete mode 100644 Lambda/demos/demo_input.txt delete mode 100644 Lambda/demos/dune delete mode 100644 Lambda/demos/interpretTests.t delete mode 100644 Lambda/demos/parsingTests.t delete mode 100644 Lambda/dune delete mode 100644 Lambda/dune-project delete mode 100644 Lambda/lib/Pprintast.ml delete mode 100644 Lambda/lib/Pprintast.mli delete mode 100644 Lambda/lib/Printast.ml delete mode 100644 Lambda/lib/Printast.mli delete mode 100644 Lambda/lib/ast.mli delete mode 100644 Lambda/lib/dune delete mode 100644 Lambda/lib/interpret.ml delete mode 100644 Lambda/lib/interpret.mli delete mode 100644 Lambda/lib/lambda.ml delete mode 100644 Lambda/lib/lambda.mli delete mode 100644 Lambda/lib/parser.ml delete mode 100644 Lambda/lib/parser.mli delete mode 100644 Lambda/lib/tests.ml delete mode 100644 Lambda/lib/utils.ml delete mode 100644 Lambda/lib/utils.mli delete mode 100644 Lambda/repl.t delete mode 100644 Lua/.gitignore delete mode 100644 Lua/.ocamlformat delete mode 100644 Lua/COPYING delete mode 100644 Lua/COPYING.CC0 delete mode 100644 Lua/COPYING.LESSER delete mode 100644 Lua/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Lua/Lambda.opam delete mode 100644 Lua/Makefile delete mode 100644 Lua/README.md delete mode 100644 Lua/REPL.ml delete mode 100644 Lua/demos/demoAO.ml delete mode 100644 Lua/demos/demoNO.ml delete mode 100644 Lua/demos/demoParse.ml delete mode 100644 Lua/demos/demo_input.txt delete mode 100644 Lua/demos/dune delete mode 100644 Lua/demos/interpretTests.t delete mode 100644 Lua/demos/parsingTests.t delete mode 100644 Lua/dune delete mode 100644 Lua/dune-project delete mode 100644 Lua/lib/Pprintast.ml delete mode 100644 Lua/lib/Pprintast.mli delete mode 100644 Lua/lib/Printast.ml delete mode 100644 Lua/lib/Printast.mli delete mode 100644 Lua/lib/ast.mli delete mode 100644 Lua/lib/dune delete mode 100644 Lua/lib/interpret.ml delete mode 100644 Lua/lib/interpret.mli delete mode 100644 Lua/lib/lambda.ml delete mode 100644 Lua/lib/lambda.mli delete mode 100644 Lua/lib/parser.ml delete mode 100644 Lua/lib/parser.mli delete mode 100644 Lua/lib/tests.ml delete mode 100644 Lua/lib/utils.ml delete mode 100644 Lua/lib/utils.mli delete mode 100644 Lua/repl.t delete mode 100644 Menhir/.gitignore delete mode 100644 Menhir/.ocamlformat delete mode 100644 Menhir/COPYING delete mode 100644 Menhir/COPYING.CC0 delete mode 100644 Menhir/COPYING.LESSER delete mode 100644 Menhir/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Menhir/Lambda.opam delete mode 100644 Menhir/Makefile delete mode 100644 Menhir/README.md delete mode 100644 Menhir/REPL.ml delete mode 100644 Menhir/demos/demoAO.ml delete mode 100644 Menhir/demos/demoNO.ml delete mode 100644 Menhir/demos/demoParse.ml delete mode 100644 Menhir/demos/demo_input.txt delete mode 100644 Menhir/demos/dune delete mode 100644 Menhir/demos/interpretTests.t delete mode 100644 Menhir/demos/parsingTests.t delete mode 100644 Menhir/dune delete mode 100644 Menhir/dune-project delete mode 100644 Menhir/lib/Pprintast.ml delete mode 100644 Menhir/lib/Pprintast.mli delete mode 100644 Menhir/lib/Printast.ml delete mode 100644 Menhir/lib/Printast.mli delete mode 100644 Menhir/lib/ast.mli delete mode 100644 Menhir/lib/dune delete mode 100644 Menhir/lib/interpret.ml delete mode 100644 Menhir/lib/interpret.mli delete mode 100644 Menhir/lib/lambda.ml delete mode 100644 Menhir/lib/lambda.mli delete mode 100644 Menhir/lib/parser.ml delete mode 100644 Menhir/lib/parser.mli delete mode 100644 Menhir/lib/tests.ml delete mode 100644 Menhir/lib/utils.ml delete mode 100644 Menhir/lib/utils.mli delete mode 100644 Menhir/repl.t delete mode 100644 OCaml+PolymorphicVariants/.gitignore delete mode 100644 OCaml+PolymorphicVariants/.ocamlformat delete mode 100644 OCaml+PolymorphicVariants/COPYING delete mode 100644 OCaml+PolymorphicVariants/COPYING.CC0 delete mode 100644 OCaml+PolymorphicVariants/COPYING.LESSER delete mode 100644 OCaml+PolymorphicVariants/Makefile delete mode 100644 OCaml+PolymorphicVariants/OCaml+PolymorphicVariants.opam delete mode 100644 OCaml+PolymorphicVariants/README.md delete mode 100644 OCaml+PolymorphicVariants/demos/demoParse.ml delete mode 100644 OCaml+PolymorphicVariants/demos/demoParse.t delete mode 100644 OCaml+PolymorphicVariants/demos/dune delete mode 100644 OCaml+PolymorphicVariants/dune delete mode 100644 OCaml+PolymorphicVariants/dune-project delete mode 100644 OCaml+PolymorphicVariants/lib/ast.ml delete mode 100644 OCaml+PolymorphicVariants/lib/dune delete mode 100644 OCaml+PolymorphicVariants/lib/parser.ml delete mode 100644 OCamlTyEff/.gitignore delete mode 100644 OCamlTyEff/.ocamlformat delete mode 100644 OCamlTyEff/LICENSE delete mode 100644 OCamlTyEff/OCamlTyEff.opam delete mode 100644 OCamlTyEff/README.md delete mode 100644 OCamlTyEff/bin/dune delete mode 100644 OCamlTyEff/bin/interpret.ml delete mode 100644 OCamlTyEff/bin/interpret.t delete mode 100644 OCamlTyEff/dune delete mode 100644 OCamlTyEff/dune-project delete mode 100644 OCamlTyEff/lib/ast/ast.ml delete mode 100644 OCamlTyEff/lib/ast/dune delete mode 100644 OCamlTyEff/lib/parser/common.ml delete mode 100644 OCamlTyEff/lib/parser/common.mli delete mode 100644 OCamlTyEff/lib/parser/dune delete mode 100644 OCamlTyEff/lib/parser/expr.ml delete mode 100644 OCamlTyEff/lib/parser/expr.mli delete mode 100644 OCamlTyEff/lib/parser/parser.ml delete mode 100644 OCamlTyEff/lib/parser/parser.mli delete mode 100644 OCamlTyEff/lib/parser/pattern.ml delete mode 100644 OCamlTyEff/lib/parser/pattern.mli delete mode 100644 OCamlTyEff/lib/parser/structure.ml delete mode 100644 OCamlTyEff/lib/parser/structure.mli delete mode 100644 OCamlTyEff/lib/parser/test.ml delete mode 100644 OCamlWithEffects/.gitignore delete mode 100644 OCamlWithEffects/.ocamlformat delete mode 100644 OCamlWithEffects/COPYING delete mode 100644 OCamlWithEffects/COPYING.CC0 delete mode 100644 OCamlWithEffects/COPYING.LESSER delete mode 100644 OCamlWithEffects/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 OCamlWithEffects/Makefile delete mode 100644 OCamlWithEffects/OCamlWithEffects.opam delete mode 100644 OCamlWithEffects/README.md delete mode 100644 OCamlWithEffects/demos/demoFact.ml delete mode 100644 OCamlWithEffects/demos/demoFact.t delete mode 100644 OCamlWithEffects/demos/dune delete mode 100644 OCamlWithEffects/dune delete mode 100644 OCamlWithEffects/dune-project delete mode 100644 OCamlWithEffects/lib/ast.ml delete mode 100644 OCamlWithEffects/lib/dune delete mode 100644 OCamlWithEffects/lib/parser.ml delete mode 100644 OCamlWithWeakTypeVariables/.gitignore delete mode 100644 OCamlWithWeakTypeVariables/.ocamlformat delete mode 100644 OCamlWithWeakTypeVariables/COPYING delete mode 100644 OCamlWithWeakTypeVariables/COPYING.CC0 delete mode 100644 OCamlWithWeakTypeVariables/COPYING.LESSER delete mode 100644 OCamlWithWeakTypeVariables/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 OCamlWithWeakTypeVariables/Lambda.opam delete mode 100644 OCamlWithWeakTypeVariables/Makefile delete mode 100644 OCamlWithWeakTypeVariables/README.md delete mode 100644 OCamlWithWeakTypeVariables/REPL.ml delete mode 100644 OCamlWithWeakTypeVariables/demos/demoAO.ml delete mode 100644 OCamlWithWeakTypeVariables/demos/demoNO.ml delete mode 100644 OCamlWithWeakTypeVariables/demos/demoParse.ml delete mode 100644 OCamlWithWeakTypeVariables/demos/demo_input.txt delete mode 100644 OCamlWithWeakTypeVariables/demos/dune delete mode 100644 OCamlWithWeakTypeVariables/demos/interpretTests.t delete mode 100644 OCamlWithWeakTypeVariables/demos/parsingTests.t delete mode 100644 OCamlWithWeakTypeVariables/dune delete mode 100644 OCamlWithWeakTypeVariables/dune-project delete mode 100644 OCamlWithWeakTypeVariables/lib/Pprintast.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/Pprintast.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/Printast.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/Printast.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/ast.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/dune delete mode 100644 OCamlWithWeakTypeVariables/lib/interpret.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/interpret.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/lambda.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/lambda.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/parser.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/parser.mli delete mode 100644 OCamlWithWeakTypeVariables/lib/tests.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/utils.ml delete mode 100644 OCamlWithWeakTypeVariables/lib/utils.mli delete mode 100644 OCamlWithWeakTypeVariables/repl.t delete mode 100644 OCaml_BidirectionalRecords/.gitignore delete mode 100644 OCaml_BidirectionalRecords/.ocamlformat delete mode 100644 OCaml_BidirectionalRecords/COPYING delete mode 100644 OCaml_BidirectionalRecords/COPYING.CC0 delete mode 100644 OCaml_BidirectionalRecords/COPYING.LESSER delete mode 100644 OCaml_BidirectionalRecords/Makefile delete mode 100644 OCaml_BidirectionalRecords/OCaml_BidirectionalRecords.opam delete mode 100644 OCaml_BidirectionalRecords/README.md delete mode 100644 OCaml_BidirectionalRecords/demos/dune delete mode 100644 OCaml_BidirectionalRecords/dune delete mode 100644 OCaml_BidirectionalRecords/dune-project delete mode 100644 OCaml_BidirectionalRecords/lib/ast.ml delete mode 100644 OCaml_BidirectionalRecords/lib/dune delete mode 100644 OCaml_BidirectionalRecords/lib/parser.ml delete mode 100644 OCaml_BidirectionalRecords/lib/tests.ml delete mode 100644 OCaml_ExtensibleVariantTypes/.gitignore delete mode 100644 OCaml_ExtensibleVariantTypes/.ocamlformat delete mode 100644 OCaml_ExtensibleVariantTypes/COPYING delete mode 100644 OCaml_ExtensibleVariantTypes/COPYING.CC0 delete mode 100644 OCaml_ExtensibleVariantTypes/COPYING.LESSER delete mode 100644 OCaml_ExtensibleVariantTypes/Makefile delete mode 100644 OCaml_ExtensibleVariantTypes/OCaml_ExtensibleVariantTypes.opam delete mode 100644 OCaml_ExtensibleVariantTypes/README.md delete mode 100644 OCaml_ExtensibleVariantTypes/REPL.ml delete mode 100644 OCaml_ExtensibleVariantTypes/demos/demoParse.ml delete mode 100644 OCaml_ExtensibleVariantTypes/demos/demo_input.txt delete mode 100644 OCaml_ExtensibleVariantTypes/demos/dune delete mode 100644 OCaml_ExtensibleVariantTypes/demos/parsingTests.t delete mode 100644 OCaml_ExtensibleVariantTypes/dune delete mode 100644 OCaml_ExtensibleVariantTypes/dune-project delete mode 100644 OCaml_ExtensibleVariantTypes/lib/ast.ml delete mode 100644 OCaml_ExtensibleVariantTypes/lib/dune delete mode 100644 OCaml_ExtensibleVariantTypes/lib/parser.ml delete mode 100644 OCaml_ExtensibleVariantTypes/lib/tests.ml delete mode 100644 OCaml_ExtensibleVariantTypes/repl.t delete mode 100644 Ocaml+ADT/.gitignore delete mode 100644 Ocaml+ADT/.ocamlformat delete mode 100644 Ocaml+ADT/COPYING delete mode 100644 Ocaml+ADT/COPYING.CC0 delete mode 100644 Ocaml+ADT/COPYING.LESSER delete mode 100644 Ocaml+ADT/Makefile delete mode 100644 Ocaml+ADT/Ocaml+ADT.opam delete mode 100644 Ocaml+ADT/README.md delete mode 100644 Ocaml+ADT/demos/demoFact.ml delete mode 100644 Ocaml+ADT/demos/demoFact.t delete mode 100644 Ocaml+ADT/demos/dune delete mode 100644 Ocaml+ADT/dune delete mode 100644 Ocaml+ADT/dune-project delete mode 100644 Ocaml+ADT/lib/ast.ml delete mode 100644 Ocaml+ADT/lib/dune delete mode 100644 Ocaml+ADT/lib/parser.ml delete mode 100644 Ocaml+printf/.gitignore delete mode 100644 Ocaml+printf/.ocamlformat delete mode 100644 Ocaml+printf/COPYING delete mode 100644 Ocaml+printf/COPYING.CC0 delete mode 100644 Ocaml+printf/COPYING.LESSER delete mode 100644 Ocaml+printf/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Ocaml+printf/Makefile delete mode 100644 Ocaml+printf/Ocaml+printf.opam delete mode 100644 Ocaml+printf/README.md delete mode 100644 Ocaml+printf/demos/demoInfer.ml delete mode 100644 Ocaml+printf/demos/demoInfer.t delete mode 100644 Ocaml+printf/demos/demoInterpreter.ml delete mode 100644 Ocaml+printf/demos/demoInterpreter.t delete mode 100644 Ocaml+printf/demos/demoParse.ml delete mode 100644 Ocaml+printf/demos/demoParse.t delete mode 100644 Ocaml+printf/demos/dune delete mode 100644 Ocaml+printf/dune-project delete mode 100644 Ocaml+printf/lib/ast.ml delete mode 100644 Ocaml+printf/lib/dune delete mode 100644 Ocaml+printf/lib/inferencer.ml delete mode 100644 Ocaml+printf/lib/inferencer.mli delete mode 100644 Ocaml+printf/lib/interpreter.ml delete mode 100644 Ocaml+printf/lib/interpreter.mli delete mode 100644 Ocaml+printf/lib/parser.ml delete mode 100644 Ocaml+printf/lib/parser.mli delete mode 100644 Ocaml+printf/lib/pprint.ml delete mode 100644 Ocaml+printf/lib/pprint.mli delete mode 100644 Ocaml+printf/lib/tests/infer_tests.ml delete mode 100644 Ocaml+printf/lib/tests/infer_tests.mli delete mode 100644 Ocaml+printf/lib/tests/interpret_tests.ml delete mode 100644 Ocaml+printf/lib/tests/interpret_tests.mli delete mode 100644 Ocaml+printf/lib/tests/parser_tests.ml delete mode 100644 Ocaml+printf/lib/tests/parser_tests.mli delete mode 100644 Ocaml+printf/lib/typedtree.ml delete mode 100644 Ocaml+printf/lib/typedtree.mli delete mode 100644 OcamlOOP/.gitignore delete mode 100644 OcamlOOP/.ocamlformat delete mode 100644 OcamlOOP/COPYING delete mode 100644 OcamlOOP/COPYING.CC0 delete mode 100644 OcamlOOP/COPYING.LESSER delete mode 100644 OcamlOOP/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 OcamlOOP/Makefile delete mode 100644 OcamlOOP/OcamlOOP.opam delete mode 100644 OcamlOOP/README.md delete mode 100644 OcamlOOP/demos/demo.ml delete mode 100644 OcamlOOP/demos/demo_fact.ml delete mode 100644 OcamlOOP/demos/demo_obj.ml delete mode 100644 OcamlOOP/demos/demo_obj1.ml delete mode 100644 OcamlOOP/demos/dune delete mode 100644 OcamlOOP/demos/test.t delete mode 100644 OcamlOOP/dune delete mode 100644 OcamlOOP/dune-project delete mode 100644 OcamlOOP/lib/ast.ml delete mode 100644 OcamlOOP/lib/dune delete mode 100644 OcamlOOP/lib/parser.ml delete mode 100644 Parallel_execution_simulation/.gitignore delete mode 100644 Parallel_execution_simulation/.ocamlformat delete mode 100644 Parallel_execution_simulation/COPYING delete mode 100644 Parallel_execution_simulation/COPYING.CC0 delete mode 100644 Parallel_execution_simulation/COPYING.LESSER delete mode 100644 Parallel_execution_simulation/Makefile delete mode 100644 Parallel_execution_simulation/Parallel_execution_simulation.opam delete mode 100644 Parallel_execution_simulation/README.md delete mode 100644 Parallel_execution_simulation/demos/demoParser.ml delete mode 100644 Parallel_execution_simulation/demos/dune delete mode 100644 Parallel_execution_simulation/dune delete mode 100644 Parallel_execution_simulation/dune-project delete mode 100644 Parallel_execution_simulation/lib/ast.ml delete mode 100644 Parallel_execution_simulation/lib/dune delete mode 100644 Parallel_execution_simulation/lib/parser.ml delete mode 100644 Parallel_execution_simulation/lib/parser.mli delete mode 100644 PrologDatalog/.gitignore delete mode 100644 PrologDatalog/.ocamlformat delete mode 100644 PrologDatalog/COPYING delete mode 100644 PrologDatalog/COPYING.CC0 delete mode 100644 PrologDatalog/COPYING.LESSER delete mode 100644 PrologDatalog/Makefile delete mode 100644 PrologDatalog/PrologDatalog.opam delete mode 100644 PrologDatalog/README.md delete mode 100644 PrologDatalog/dune delete mode 100644 PrologDatalog/dune-project delete mode 100644 PrologDatalog/lib/ast.ml delete mode 100644 PrologDatalog/lib/dune delete mode 100644 PrologDatalog/lib/parser.ml delete mode 100644 PrologDatalog/lib/parser.mli delete mode 100644 Python/.gitignore delete mode 100644 Python/.ocamlformat delete mode 100644 Python/COPYING delete mode 100644 Python/COPYING.CC0 delete mode 100644 Python/COPYING.LESSER delete mode 100644 Python/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 Python/Makefile delete mode 100644 Python/Python.opam delete mode 100644 Python/README.md delete mode 100644 Python/REPL.ml delete mode 100644 Python/demos/demo_fact.ml delete mode 100644 Python/demos/dune delete mode 100644 Python/demos/interpreter_test.ml delete mode 100644 Python/demos/test.t delete mode 100644 Python/dune delete mode 100644 Python/dune-project delete mode 100644 Python/lib/ast.ml delete mode 100644 Python/lib/dune delete mode 100644 Python/lib/interpreter.ml delete mode 100644 Python/lib/interpreter.mli delete mode 100644 Python/lib/parser.ml delete mode 100644 Python/lib/parser.mli delete mode 100644 Python/lib/tests.ml delete mode 100644 Python/lib/tests.mli delete mode 100644 Python/repl.t delete mode 100644 Refal5/.gitignore delete mode 100644 Refal5/.ocamlformat delete mode 100644 Refal5/COPYING delete mode 100644 Refal5/COPYING.CC0 delete mode 100644 Refal5/COPYING.LESSER delete mode 100644 Refal5/Lambda.opam delete mode 100644 Refal5/Makefile delete mode 100644 Refal5/README.md delete mode 100644 Refal5/REPL.ml delete mode 100644 Refal5/demos/demoAO.ml delete mode 100644 Refal5/demos/demoNO.ml delete mode 100644 Refal5/demos/demoParse.ml delete mode 100644 Refal5/demos/demo_input.txt delete mode 100644 Refal5/demos/dune delete mode 100644 Refal5/demos/interpretTests.t delete mode 100644 Refal5/demos/parsingTests.t delete mode 100644 Refal5/dune delete mode 100644 Refal5/dune-project delete mode 100644 Refal5/lib/Pprintast.ml delete mode 100644 Refal5/lib/Pprintast.mli delete mode 100644 Refal5/lib/Printast.ml delete mode 100644 Refal5/lib/Printast.mli delete mode 100644 Refal5/lib/ast.mli delete mode 100644 Refal5/lib/dune delete mode 100644 Refal5/lib/interpret.ml delete mode 100644 Refal5/lib/interpret.mli delete mode 100644 Refal5/lib/lambda.ml delete mode 100644 Refal5/lib/lambda.mli delete mode 100644 Refal5/lib/parser.ml delete mode 100644 Refal5/lib/parser.mli delete mode 100644 Refal5/lib/tests.ml delete mode 100644 Refal5/lib/utils.ml delete mode 100644 Refal5/lib/utils.mli delete mode 100644 Refal5/repl.t delete mode 100644 Ruby/.gitignore delete mode 100644 Ruby/.ocamlformat delete mode 100644 Ruby/COPYING delete mode 100644 Ruby/COPYING.CC0 delete mode 100644 Ruby/COPYING.LESSER delete mode 100644 Ruby/Makefile delete mode 100644 Ruby/README.md delete mode 100644 Ruby/Ruby.opam delete mode 100644 Ruby/demos/demoParser.ml delete mode 100644 Ruby/demos/demoParser.t delete mode 100644 Ruby/demos/dune delete mode 100644 Ruby/dune delete mode 100644 Ruby/dune-project delete mode 100644 Ruby/examples/facfib.rb delete mode 100644 Ruby/lib/ast.ml delete mode 100644 Ruby/lib/dune delete mode 100644 Ruby/lib/interpret.ml delete mode 100644 Ruby/lib/interpret.mli delete mode 100644 Ruby/lib/parser.ml delete mode 100644 Ruby/lib/tests.ml delete mode 100644 Ruby/lib/utils.ml delete mode 100644 Ruby/lib/utils.mli delete mode 100644 SchemeDelimCC/.gitignore delete mode 100644 SchemeDelimCC/.ocamlformat delete mode 100644 SchemeDelimCC/COPYING delete mode 100644 SchemeDelimCC/COPYING.CC0 delete mode 100644 SchemeDelimCC/COPYING.LESSER delete mode 100644 SchemeDelimCC/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 SchemeDelimCC/Lambda.opam delete mode 100644 SchemeDelimCC/Makefile delete mode 100644 SchemeDelimCC/README.md delete mode 100644 SchemeDelimCC/REPL.ml delete mode 100644 SchemeDelimCC/demos/demoAO.ml delete mode 100644 SchemeDelimCC/demos/demoNO.ml delete mode 100644 SchemeDelimCC/demos/demoParse.ml delete mode 100644 SchemeDelimCC/demos/demo_input.txt delete mode 100644 SchemeDelimCC/demos/dune delete mode 100644 SchemeDelimCC/demos/interpretTests.t delete mode 100644 SchemeDelimCC/demos/parsingTests.t delete mode 100644 SchemeDelimCC/dune delete mode 100644 SchemeDelimCC/dune-project delete mode 100644 SchemeDelimCC/lib/Pprintast.ml delete mode 100644 SchemeDelimCC/lib/Pprintast.mli delete mode 100644 SchemeDelimCC/lib/Printast.ml delete mode 100644 SchemeDelimCC/lib/Printast.mli delete mode 100644 SchemeDelimCC/lib/ast.mli delete mode 100644 SchemeDelimCC/lib/dune delete mode 100644 SchemeDelimCC/lib/interpret.ml delete mode 100644 SchemeDelimCC/lib/interpret.mli delete mode 100644 SchemeDelimCC/lib/lambda.ml delete mode 100644 SchemeDelimCC/lib/lambda.mli delete mode 100644 SchemeDelimCC/lib/parser.ml delete mode 100644 SchemeDelimCC/lib/parser.mli delete mode 100644 SchemeDelimCC/lib/tests.ml delete mode 100644 SchemeDelimCC/lib/utils.ml delete mode 100644 SchemeDelimCC/lib/utils.mli delete mode 100644 SchemeDelimCC/repl.t rename asm/asm.opam => asm.opam (100%) delete mode 100644 asm/.gitignore delete mode 100644 asm/COPYING delete mode 100644 asm/COPYING.CC0 delete mode 100644 asm/COPYING.LESSER delete mode 100644 asm/README.md delete mode 100644 asm/dune rename {asm/bin => bin}/demoInterpreter.ml (100%) rename {asm/bin => bin}/demoInterpreter.t (100%) rename {asm/bin => bin}/demoParser.ml (100%) rename {asm/bin => bin}/demoParser.t (100%) rename {asm/bin => bin}/dune (100%) rename {asm/bin => bin}/sources/fib.asm (100%) rename {asm/bin => bin}/sources/matrix.asm (100%) rename {asm/bin => bin}/sources/scalar.asm (100%) delete mode 100755 build_latest.sh delete mode 100755 detect_latest.sh delete mode 100644 detect_latest_pr.ml delete mode 100755 detect_latest_pr.sh rename asm/devbox.json => devbox.json (100%) rename asm/devbox.lock => devbox.lock (100%) rename CSharpExceptions/dune => dune (100%) rename asm/dune-project => dune-project (100%) delete mode 100644 exam.md delete mode 100755 find_clones.py rename {asm/lib => lib}/ast/ast.ml (100%) rename {asm/lib => lib}/ast/dune (100%) rename {asm/lib => lib}/interpreter/containers.ml (100%) rename {asm/lib => lib}/interpreter/containers.mli (100%) rename {asm/lib => lib}/interpreter/dune (100%) rename {asm/lib => lib}/interpreter/interpreter.ml (100%) rename {asm/lib => lib}/interpreter/interpreter.mli (100%) rename {asm/lib => lib}/interpreter/state.ml (100%) rename {asm/lib => lib}/interpreter/state.mli (100%) rename {asm/lib => lib}/parser/common.ml (100%) rename {asm/lib => lib}/parser/common.mli (100%) rename {asm/lib => lib}/parser/directive.ml (100%) rename {asm/lib => lib}/parser/directive.mli (100%) rename {asm/lib => lib}/parser/dune (100%) rename {asm/lib => lib}/parser/immediate.ml (100%) rename {asm/lib => lib}/parser/immediate.mli (100%) rename {asm/lib => lib}/parser/operand.ml (100%) rename {asm/lib => lib}/parser/operand.mli (100%) rename {asm/lib => lib}/parser/parser.ml (100%) rename {asm/lib => lib}/parser/parser.mli (100%) rename {asm/lib => lib}/parser/register.ml (100%) rename {asm/lib => lib}/parser/register.mli (100%) rename {asm/lib => lib}/parser/statement.ml (100%) rename {asm/lib => lib}/parser/statement.mli (100%) delete mode 100755 lint_filesystem.py delete mode 100644 mini-SQL/.gitignore delete mode 100644 mini-SQL/.ocamlformat delete mode 100644 mini-SQL/COPYING delete mode 100644 mini-SQL/COPYING.CC0 delete mode 100644 mini-SQL/COPYING.LESSER delete mode 100644 mini-SQL/Makefile delete mode 100644 mini-SQL/README.md delete mode 100644 mini-SQL/REPL.ml delete mode 100644 mini-SQL/demos/demoAO.ml delete mode 100644 mini-SQL/demos/demoNO.ml delete mode 100644 mini-SQL/demos/demoParse.ml delete mode 100644 mini-SQL/demos/demo_input.txt delete mode 100644 mini-SQL/demos/dune delete mode 100644 mini-SQL/demos/parsingTests.t delete mode 100644 mini-SQL/dune delete mode 100644 mini-SQL/dune-project delete mode 100644 mini-SQL/lib/ast.ml delete mode 100644 mini-SQL/lib/dune delete mode 100644 mini-SQL/lib/parser.ml delete mode 100644 mini-SQL/lib/test.ml delete mode 100644 mini-SQL/mini-SQL.opam delete mode 100644 named and optional arguments/.gitignore delete mode 100644 named and optional arguments/.ocamlformat delete mode 100644 named and optional arguments/COPYING delete mode 100644 named and optional arguments/COPYING.CC0 delete mode 100644 named and optional arguments/COPYING.LESSER delete mode 100644 named and optional arguments/DONT_REMOVE_THIS_DIRECTORY.md delete mode 100644 named and optional arguments/Lambda.opam delete mode 100644 named and optional arguments/Makefile delete mode 100644 named and optional arguments/README.md delete mode 100644 named and optional arguments/REPL.ml delete mode 100644 named and optional arguments/demos/demoAO.ml delete mode 100644 named and optional arguments/demos/demoNO.ml delete mode 100644 named and optional arguments/demos/demoParse.ml delete mode 100644 named and optional arguments/demos/demo_input.txt delete mode 100644 named and optional arguments/demos/dune delete mode 100644 named and optional arguments/demos/interpretTests.t delete mode 100644 named and optional arguments/demos/parsingTests.t delete mode 100644 named and optional arguments/dune delete mode 100644 named and optional arguments/dune-project delete mode 100644 named and optional arguments/lib/Pprintast.ml delete mode 100644 named and optional arguments/lib/Pprintast.mli delete mode 100644 named and optional arguments/lib/Printast.ml delete mode 100644 named and optional arguments/lib/Printast.mli delete mode 100644 named and optional arguments/lib/ast.mli delete mode 100644 named and optional arguments/lib/dune delete mode 100644 named and optional arguments/lib/interpret.ml delete mode 100644 named and optional arguments/lib/interpret.mli delete mode 100644 named and optional arguments/lib/lambda.ml delete mode 100644 named and optional arguments/lib/lambda.mli delete mode 100644 named and optional arguments/lib/parser.ml delete mode 100644 named and optional arguments/lib/parser.mli delete mode 100644 named and optional arguments/lib/tests.ml delete mode 100644 named and optional arguments/lib/utils.ml delete mode 100644 named and optional arguments/lib/utils.mli delete mode 100644 named and optional arguments/repl.t delete mode 100644 tasks.md diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs deleted file mode 100644 index e69de29bb..000000000 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index a5277f7b8..000000000 --- a/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -*.ml* text eol=lf linguist-language=OCaml -*.rst text eol=lf -*.c text eol=lf -*.t text eol=lf -linguist-detectable -dune text eol=lf -dune.inc text eol=lf -.gitignore text eol=lf -.gitattributes text eol=lf - diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 561ddd73e..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,2 +0,0 @@ -#* @Kakadu - diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/.github/add_comment.ml b/.github/add_comment.ml deleted file mode 100644 index 13a479f21..000000000 --- a/.github/add_comment.ml +++ /dev/null @@ -1,166 +0,0 @@ -#use "topfind";; -#require "curly";; -#require "yojson";; -#require "str";; - -type filename = string -type action = - | Put_comment of filename - | Remove_comment of string - | Delete_comment_by_id of int - | No_action -type config = - { mutable action: action - ; mutable token: string - ; mutable issue: int - ; mutable user: string - ; mutable repo: string - } -let config = - let c = { action=No_action; token=""; issue = 0; user="Kakadu"; repo="comp23hw" } in - Arg.parse - [ ("-file", Arg.String (fun s -> c.action <- Put_comment s), " input file ") - ; ("-remove", Arg.String (fun s -> c.action <- Remove_comment s), " remove comments with text") - ; ("-delete-comment", Arg.Int(fun n -> c.action <- Delete_comment_by_id n), " delete comment by id") - ; ("-token", Arg.String (fun s -> c.token <- s ), " access token") - ; ("-issue", Arg.Int (fun s -> c.issue <- s ), " issue/PR number") - ; ("-user", Arg.String (fun s -> c.user <- s ), " username") - ; ("-repo", Arg.String (fun s -> c.repo <- s ), " repo") - ] - (fun _ -> assert false) - ""; - c - -let log fmt = - Format.kasprintf (print_endline) fmt - -let headers = - [ "Authorization", Printf.sprintf "Bearer %s" config.token - ; "Accept", "application/vnd.github+json" - ; "X-GitHub-Api-Version", "2022-11-28" - ] - -let add_comment ~filename = - let url = - Printf.sprintf - "https://api.github.com/repos/%s/%s/issues/%d/comments" - config.user - config.repo - config.issue - in - let data = In_channel.with_open_text filename (fun ch -> - let s = In_channel.input_all ch in - s - (* |> Str.global_replace (Str.regexp "\n") "\\n" *) - (* |> Str.global_replace (Str.regexp "'") "'\\''" *) - ) - in - let body = - `Assoc [ "body", `String data ] - |> Yojson.Safe.pretty_to_string - in - (match Curly.(run (Request.make ~body ~headers ~url ~meth:`POST ())) with - | Ok ({ Curly.Response.code = 401; _ } as x) -> (* Bad credentials *) - Format.printf "status: %d\n" x.Curly.Response.code; - Format.printf "body: %s\n" x.Curly.Response.body; - exit 1 - | Ok x -> - Format.printf "status: %d\n" x.Curly.Response.code; - Format.printf "body: %s\n" x.Curly.Response.body; - true - | Error e -> - Format.eprintf "Failed: %a" Curly.Error.pp e; - false) - -let make_comment_info id ~user body = - (id, user, body) -let assoc_string name j = - match j with - | `Assoc xs -> (match List.assoc name xs with `String s -> s | _ -> assert false) - | _ -> assert false - -let assoc_int name j = - match (j: Yojson.Safe.t) with - | `Assoc xs -> (match List.assoc name xs with `Int s -> s | _ -> assert false) - | _ -> assert false - -let find_comments () = - let url = - Printf.sprintf - "https://api.github.com/repos/%s/%s/issues/%d/comments" - config.user - config.repo - config.issue - in - (match Curly.(get ~headers url) with - | Error e -> - Format.eprintf "Failed: %a" Curly.Error.pp e; - Result.error() - | Ok x -> - Format.printf "status: %d\n" x.Curly.Response.code; - Format.printf "body: %s\n" x.Curly.Response.body; - let j = Yojson.Safe.from_string x.Curly.Response.body in - let js = match j with - | `List js -> js - | _ -> assert false in - Result.Ok ( - js |> List.map (function - | (`Assoc kvs as j) -> - make_comment_info - (assoc_int "id" j) - (assoc_string "body" j) - ~user:(match List.assoc "user" kvs with - | (`Assoc kvs) as j-> assoc_string "login" j - | _ -> assert false) - | _ -> assert false - ) - ) - ) - - -let delete_comment comment_id = - let url = - Printf.sprintf - "https://api.github.com/repos/%s/%s/issues/comments/%d" - config.user - config.repo - comment_id - in - log "Delete using url %S." url; - (match Curly.(delete ~headers url) with - | Error e -> - Format.eprintf "Failed: %a" Curly.Error.pp e; - false - | Ok x -> - Format.printf "status: %d\n" x.Curly.Response.code; - true) - -let () = - let (let*) = Result.bind in - ignore (match config.action with - | No_action -> Printf.eprintf "No action specified\n"; exit 1 - | Put_comment filename -> - assert (add_comment ~filename); - Result.ok () - | Delete_comment_by_id n -> - assert (delete_comment n); - Result.ok () - | Remove_comment text -> - if (String.length text = 0) - then failwith "text for search can't be empty"; - let* all_comments = find_comments () in - let __ () = List.iter (fun (id, user, body) -> - Printf.printf "%d\n%s\n%s\n\n" id user body - ) all_comments - in - let ids_to_remove = - List.filter_map (fun (id, _, body) -> - match Str.search_forward (Str.regexp_string text) body 0 with - | _ -> Some id - | exception Not_found -> None - ) all_comments in - List.iter (fun n -> - Printf.printf "removing %d...\n" n; - assert(delete_comment n); - ) ids_to_remove; - Result.ok ()) diff --git a/.github/check_rdjson.sh b/.github/check_rdjson.sh deleted file mode 100755 index 358196ce0..000000000 --- a/.github/check_rdjson.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -if [ "$#" -eq "0" ]; then - echo "No file specified" - exit 1 -fi - -FILENAME=$1 -LC=$(wc -l $FILENAME | cut -f1 -d' ') -# echo $LC - -if [ "$LC" -gt 5 ]; then - echo "TOOMANY" -elif [ "$LC" -gt 1 ]; then - echo "FEW" -else - echo "OK" -fi \ No newline at end of file diff --git a/.github/dco.yml b/.github/dco.yml deleted file mode 100644 index fd6ee37ac..000000000 --- a/.github/dco.yml +++ /dev/null @@ -1,5 +0,0 @@ -# https://github.com/dcoapp/app Install it here -allowRemediationCommits: - individual: true -require: - members: false diff --git a/.github/make_doc_msg.sh b/.github/make_doc_msg.sh deleted file mode 100755 index 300e8a619..000000000 --- a/.github/make_doc_msg.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env sh - -REPONAME=$1 -LANGNAME=$2 -PERCENT=$3 -OUTFILE=$4 -DATE=$(TZ='Europe/Moscow' date +%F\ %k:%M) - -echo "Документация и тестовое покрытие $(cat $PERCENT) должны скоро появиться.\n\nhttps://kakadu.github.io/$REPONAME/docs/$LANGNAME\n\nhttps://kakadu.github.io/$REPONAME/cov/$LANGNAME\n\n$DATE" > $OUTFILE diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml deleted file mode 100644 index 71bd39a90..000000000 --- a/.github/workflows/PR.yml +++ /dev/null @@ -1,212 +0,0 @@ -name: Build PR - -on: - pull_request: - branches: - - 'master' -env: - OPAMROOT: /home/user/.opam - OPAMYES: true - OPAMCONFIRMLEVEL: unsafe-yes -jobs: - build: - runs-on: ubuntu-latest - container: - image: kakadu18/ocaml:fp2023 - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - - steps: - #- name: Cancel Previous Runs - # uses: styfle/cancel-workflow-action@0.11.0 - # with: - # access_token: ${{ github.token }} - - #- run: sudo apt-get update -y - # if: matrix.os != 'macos-latest' - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fix me later - - - run: | - opam pin add https://github.com/Kakadu/zanuda.git --no-action - opam reinstall zanuda --yes - - - - name: List installed OPAM packages - run: opam list - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v6 - - - name: Print Ref brach name - run: | - echo "${{ steps.branch-name.outputs.ref_branch }}" - - #- run: git remote -vvv - #- run: git branch -vvv - - # Outputs: "main" - ############# Detecting and compiling fp2023 - # Smart link about setting environment variables - # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - - if: false - #if: ${{ github.event.pull_request.user.login != 'fp2022-helper' }} - run: | - sh -x ./detect_latest_pr.sh "pull/${{ steps.branch-name.outputs.ref_branch }}" >> $GITHUB_ENV - echo "${{ env.latest }}" - - # TODO: set OCAMLRUNPARAM=b - - run: | - opam exec -- ocaml ./detect_latest_pr.ml "pull/${{ steps.branch-name.outputs.ref_branch }}" -user Kakadu -repo fp2023 >> $GITHUB_ENV - echo "${{ env.latest }}" - #if: ${{ github.event.pull_request.user.login == 'fp2022-helper' }} - - - name: Installing dependencies - run: | - sudo apt update - opam update - opam install ./${{ env.latest }} --depext-only --with-test --with-doc - opam install ./${{ env.latest }} --deps-only --with-test --with-doc - - - name: Naive linting - run: | - cd ${{ env.latest }} && python3 ../lint_filesystem.py ${{ env.latest }} - - - if: false - name: Checking ocamlformat - run: | - cd ${{ env.latest }} && opam exec -- dune build @fmt --profile=release - - - name: Compiling ${{ env.latest }}... - run: cd ${{ env.latest }} && opam exec -- dune build --profile=release - - - name: Running tests in ${{ env.latest }}... - run: cd ${{ env.latest }} && opam exec -- dune runtest --profile=release - - - name: Setting the environment - env: - LINTS_PATH: _build/default/_found_lints - run: | - echo "RDJSON_DIR_PATH=${{ env.LINTS_PATH }}" >> $GITHUB_ENV - echo "RDJSON_FILE_PATH=${{ env.LINTS_PATH }}/lints.rdjsonl" >> $GITHUB_ENV - cd ${{ env.latest }} && mkdir -p ${{ env.LINTS_PATH }} - echo "ZANUDA_REPORT_FILE_PATH=${{ env.LINTS_PATH }}/lints.txt" >> $GITHUB_ENV - - - name: Running linter in ${{ env.latest }}... - run: | - cd ${{ env.latest }} && opam exec -- zanuda -dir . -add-prefix ${{ env.latest }}/ -no-no_toplevel_eval -ordjsonl ${{ env.RDJSON_FILE_PATH }} > ${{ env.ZANUDA_REPORT_FILE_PATH }} - - - run: cat ${{ env.latest }}/${{ env.RDJSON_FILE_PATH }} - - name: Preparing lints tarball - run: | - echo ${{ env.latest }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/projectname.txt - echo ${{ github.event.pull_request.user.login }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/piarast.txt - echo ${{ github.event.number }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/PR_number.txt - echo ${{ github.event.pull_request.head.sha }} > ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/CI_COMMIT.txt - # we use commit previous from head because HEAD is merge commit by some reason - # TODO: maybe PR_number is not required - - - name: Upload linter (review.zip) artifact - uses: actions/upload-artifact@v3 - with: - name: review - path: | - ${{ env.latest }}/${{ env.RDJSON_DIR_PATH }} - - - run: echo $(git rev-parse HEAD) - - run: echo $(git rev-parse HEAD~1) - - run: echo ${{ github.event.pull_request.head.sha }} - - run: PAGER= git log - - # Omitted. It is in docker image already - #- name: Installing a clone detector - # run: npm install jscpd - - #- run: which jscpd || exit 0 - #- run: ls ~/.local/bin || exit 0 - #- run: pwd ~ || exit 0 - - - name: Looking for clones - run: | - echo ${{ env.latest }} > projectname.txt - python3 ./find_clones.py ${{ env.latest }} - #python3 -m trace --trace ./find_clones.py ${{ env.latest }} - - - run: echo ${{ github.event.number }} > PR_number.txt - - - run: cat jscpd_report.txt - - - name: Update JSCPD artifact - uses: actions/upload-artifact@v3 - with: - name: jscpd_report - path: | - jscpd_report.txt - PR_number.txt - projectname.txt - - ###################### Coverage ##################################### - - - name: Calculating coverage (1/2) - run: | - mkdir -p ${{ env.BISECT_DIR }} - cd ${{ env.latest }} && opam exec -- dune runtest --instrument-with bisect_ppx --force - env: - BISECT_DIR: /tmp/bisect_ppx_data - BISECT_FILE: /tmp/bisect_ppx_data/data - - #- run: ls ${{ env.BISECT_DIR }} - # env: - # BISECT_DIR: /tmp/bisect_ppx_data - # BISECT_FILE: /tmp/bisect_ppx_data/data - - - name: Calculating coverage (2/2) - id: calc-coverage - run: | - cd ${{ env.latest }} - mkdir -p ${{ env.BISECT_DIR }} - opam exec -- bisect-ppx-report html --coverage-path ${{ env.BISECT_DIR }} - opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }} - opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }} | cut -f3 | xargs -I{} echo "percent={}" >> $GITHUB_OUTPUT - opam exec -- bisect-ppx-report summary --coverage-path ${{ env.BISECT_DIR }} | cut -f3 -d' ' | xargs -I{} echo "{}" > _coverage/percent.txt - ls ${{ env.BISECT_DIR }} - ls _coverage - env: - BISECT_DIR: /tmp/bisect_ppx_data - BISECT_FILE: /tmp/bisect_ppx_data/data - - - run: echo ${{ env.latest }} > ${{ env.latest }}/_coverage/projectname.txt - - - name: Update coverage artifact ${{ steps.calc-coverage.outputs.percent }} - uses: actions/upload-artifact@v3 - with: - name: coverage - path: ${{ env.latest }}/_coverage - - ###################### Upload Docs ##################################### - - name: Build API documentation for ${{ env.latest }}... - run: | - opam install odoc --yes - cd ${{ env.latest }} && opam exec -- dune build @doc --profile=release - - - run: echo ${{ github.event.number }} > ${{ env.latest }}/PR_number.txt - - run: echo ${{ env.latest }} > ${{ env.latest }}/projectname.txt - - run: cp ${{ env.latest }}/_coverage/percent.txt . - - run: cp ${{ env.latest }}/_build/default/_doc/_html . -r - - - name: Update docs artifact - uses: actions/upload-artifact@v3 - with: - name: docs - path: | - _html - projectname.txt - PR_number.txt - percent.txt - #${{ env.latest }}/${{ env.RDJSON_DIR_PATH }}/CI_COMMIT.txt diff --git a/.github/workflows/PRformat.yml b/.github/workflows/PRformat.yml deleted file mode 100644 index 99d4a81c1..000000000 --- a/.github/workflows/PRformat.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Build PR (only formatting) - -on: - pull_request: - branches: - - 'master' - -env: - OPAMROOT: /home/user/.opam - OPAMYES: true -jobs: - build: - runs-on: ubuntu-latest - container: - image: kakadu18/ocaml:fp2023 - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - - steps: - #- name: Cancel Previous Runs - # uses: styfle/cancel-workflow-action@0.9.1 - # with: - # access_token: ${{ github.token }} - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 # fix me later - - - name: List installed OPAM packages - run: opam list - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v6 - - ############# Detecting and compiling fp2023 - # Smart link about setting environment variables - # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - - if: ${{ github.event.pull_request.user.login != 'fp2022-helper' }} - run: | - sh -x ./detect_latest_pr.sh "pull/${{ steps.branch-name.outputs.ref_branch }}" >> $GITHUB_ENV - echo "${{ env.latest }}" - - - if: ${{ github.event.pull_request.user.login == 'fp2022-helper' }} - run: | - opam exec -- ocaml ./detect_latest_pr.ml "pull/${{ steps.branch-name.outputs.ref_branch }}" >> $GITHUB_ENV - echo "${{ env.latest }}" - - #- name: Installing dependencies - # run: cd ${{ env.latest }} && opam install . --deps-only --with-test --with-doc - - - name: Naive linting - run: | - cd ${{ env.latest }} && python3 ../lint_filesystem.py ${{ env.latest }} - -# - name: Checking ocamlformat -# id: check-ocamlformat -# continue-on-error: true -# run: | -# echo "PROPERLY_FORMATTED=y" >> $GITHUB_ENV -# cd ${{ env.latest }} && opam exec -- dune build @fmt --profile=release || echo "PROPERLY_FORMATTED=n" >> $GITHUB_ENV - - - name: Checking ocamlformat - run: cd ${{ env.latest }} && opam exec -- dune build @fmt --profile=release - - - # TODO: onfail post a comment how to fix it - - # - name: Find a comment with OCamlformat report - # uses: peter-evans/find-comment@v2 - # id: fc - # with: - # issue-number: ${{ github.event.number }} - # body-includes: OCamlformat report for - # comment-author: github-actions[bot] - - # - name: Remove comment if build is OK and a comment was found - # if: steps.fc.outputs.comment-id != 0 - # run: | - # curl -L https://api.github.com/repos/Kakadu/fp2023/pulls/comments/${{ steps.fc.outputs.comment-id }} \ - # -X DELETE -H "Accept: application/vnd.github+json" \ - # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - # -H "X-GitHub-Api-Version: 2022-11-28" - - # TODO: move to workflow with proper authorization - #- name: Create comment - # if: ${{ env.PROPERLY_FORMATTED == 'n' }} - # uses: peter-evans/create-or-update-comment@v1 - # with: - # edit-mode: replace - # issue-number: ${{ github.event.number }} - # body: | - # ### OCamlformat report for ${{ env.latest }} - - # Format check failed. It could have two reasons: - # * You didn't configure VsCode extensions properly - # * The versions of ocamlformat differ on your machine and on CI diff --git a/.github/workflows/PrPost.yml b/.github/workflows/PrPost.yml deleted file mode 100644 index dfe8b1171..000000000 --- a/.github/workflows/PrPost.yml +++ /dev/null @@ -1,436 +0,0 @@ -name: Comment on the PR - -# read-write repo token -# access to secrets -on: - workflow_run: - workflows: ["Build PR"] - types: - - completed - -env: - OPAMROOT: /home/user/.opam - OPAMCONFIRMLEVEL: unsafe-yes - -jobs: - upload_lints: - runs-on: ubuntu-latest - container: - image: kakadu18/ocaml:fp2023 - - permissions: - pull-requests: write - if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 1 # fix me later - submodules: false - - - run: echo "conclusion = ${{ github.event.workflow_run.conclusion }}" - - - run: echo "event = ${{ github.event.workflow_run.event }}" - - - name: Download artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: PR.yml - name: review - - - - run: ls - - - run: | - echo "LANG_NAME=$(cat projectname.txt)" >> $GITHUB_ENV - echo "PIARAST_NAME=$(cat piarast.txt)" >> $GITHUB_ENV - echo "CI_PULL_REQUEST=$(cat PR_number.txt)" >> $GITHUB_ENV - echo "CI_COMMIT=$(cat CI_COMMIT.txt)" >> $GITHUB_ENV - echo "CI_REPO_OWNER=Kakadu" >> $GITHUB_ENV - - - run: | - echo "${{ env.LANG_NAME }}" - echo "${{ env.PIARAST_NAME }}" - echo "CI_PULL_REQUEST = ${{ env.CI_PULL_REQUEST }}" - echo "CI_COMMIT = ${{ env.CI_COMMIT }}" - echo "CI_REPO_OWNER = ${{ env.CI_REPO_OWNER }}" - - - run: | - opam pin add https://github.com/Kakadu/zanuda.git --no-action - opam reinstall zanuda - opam reinstall reviewer - - - run: cat lints.rdjsonl - - - name: Run reviewer - run: | - opam exec -- reviewer -token ${{ secrets.GITHUB_TOKEN }} \ - -owner ${{env.CI_REPO_OWNER}} \ - -repo ${{github.event.repository.name}} \ - -pr_number ${{ env.CI_PULL_REQUEST }} \ - -commit ${{ env.CI_COMMIT }} \ - -irdjsonl lints.rdjsonl -review - - # TODO: Maybe not deploy empty lint files - - run: | - echo "LINTS_NAME=$(date +%Y-%m-%d_%H_%M).json" >> $GITHUB_ENV - - run: | - mkdir -p lints - cp lints.rdjsonl lints/${{ env.LINTS_NAME }} - - - - name: Deploy found lints - uses: peaceiris/actions-gh-pages@v3 - with: - #github_token: ${{ secrets.FP2023_UPLOAD_LINTS }} - #personal_token: ${{ secrets.CLASSIC_TOKEN }} - personal_token: ${{ secrets.FP2023_UPLOAD_LINTS }} - # used only to publish in local repo - publish_dir: ./lints - external_repository: Kakadu/fp2021-ci-artifacts - publish_branch: master - keep_files: true - destination_dir: 2023fp/${{ env.LANG_NAME }}/ - # generate new token - # https://github.com/settings/tokens - # put it here - # https://github.com/Kakadu/fp2023/settings/secrets/actions/new - - - name: Prepare text with found lints - shell: bash - run: | - export TZ='Europe/Moscow' - echo "Linter report from $(date +%F\ %k:%M), for mini language ${{ env.LANG_NAME }}" > text.md - echo '```' >> text.md - cat lints.txt >> text.md - echo '```' >> text.md - - #- run: cat text.md - - - name: Find a comment with linter report - uses: peter-evans/find-comment@v2 - id: fc-linter - with: - issue-number: ${{ env.CI_PULL_REQUEST }} - body-includes: Linter report from - comment-author: Kakadu - - - name: Tracing ${{ steps.fc-linter.outputs.comment-id }} - run: echo "${{ steps.fc-linter.outputs.comment-id }}" - - - name: Manually remove comment '${{ steps.fc-linter.outputs.comment-id }}' with lints - if: ${{ steps.fc-linter.outputs.comment-id != 0 }} - run: > - opam exec -- ocaml .github/add_comment.ml \ - -token ${{ secrets.GITHUB_TOKEN }} \ - -issue ${{ env.CI_PULL_REQUEST }} \ - -delete-comment ${{ steps.fc-linter.outputs.comment-id }} \ - -user Kakadu \ - -repo comp23hw - - # The way to remove comments changes to prevent pulling extra docker image should exist. - #- name: Delete old comment - # uses: jungwinter/comment@v1 - # if: ${{ steps.fc.outputs.comment-id != 0 }} - # with: - # type: delete - # comment_id: ${{ steps.fc.outputs.comment-id }} - # token: ${{ secrets.GITHUB_TOKEN }} - -# - name: Create comment -# uses: mshick/add-pr-comment@v2 -# with: -# message: ${{ steps.read-escaped-markdown.outputs.contents }} -# issue: ${{ env.CI_PULL_REQUEST }} -# repo-owner: Kakadu -# repo-name: comp23hw -# #refresh-message-position: true -# proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app - -# - uses: mshick/add-pr-comment@v2 -# with: -# message: Hello from lints -# issue: ${{ env.CI_PULL_REQUEST }} -# repo-token: ${{ secrets.CLASSIC_TOKEN }} -# repo-owner: Kakadu -# repo-name: comp23hw -# proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app - - - run: opam list - - name: Adding a comment from text.md via OCaml script - run: > - opam exec -- ocaml .github/add_comment.ml -file text.md \ - -token ${{ secrets.GITHUB_TOKEN }} \ - -issue ${{ env.CI_PULL_REQUEST }} \ - -repo fp2023 \ - -user Kakadu - - - shell: bash - run: echo "LINTER_RESOLUTION=$(bash .github/check_rdjson.sh lints.rdjsonl)" >> $GITHUB_ENV - - - name: Tag PR as FEW linter complains - if: ${{ env.LINTER_RESOLUTION == 'FEW' }} - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.setLabels({ - issue_number: ${{ env.CI_PULL_REQUEST }}, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["A_FEW_LINTS"] - }) - - - name: Tag PR as TOOMANY linter complains - if: ${{ env.LINTER_RESOLUTION == 'TOOMANY' }} - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.setLabels({ - issue_number: ${{ env.CI_PULL_REQUEST }}, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["TOO_MANY_LINTS"] - }) - - - name: Tag PR as OK linter complains - if: ${{ env.LINTER_RESOLUTION == 'OK' }} - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.setLabels({ - issue_number: ${{ env.CI_PULL_REQUEST }}, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [] - }) - - ################################################################################################### - upload_docs: - runs-on: ubuntu-latest - container: - image: kakadu18/ocaml:fp2023 - #options: --user root - #permissions: - # pull-requests: write - if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download odoc artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: PR.yml - name: docs - path: _docs - - #- run: ls docs - - run: | - echo "LANG_NAME=$(cat _docs/projectname.txt)" >> $GITHUB_ENV - echo "PR_NUMBER=$(cat _docs/PR_number.txt)" >> $GITHUB_ENV - - run: | - echo "${{ env.LANG_NAME }}" - echo "${{ env.PR_NUMBER }}" - # LANG_NAME is required for uploading docs. - # PR_NUMBER -- for adding a comment - - - name: Deploy documentation - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - #github_token: ${{ secrets.FP2023_UPLOAD_LINTS }} - #personal_token: ${{ secrets.CLASSIC_TOKEN }} # seems to be expired - #github_token: ${{ secrets.PAT1 }} # used only to publish in local repo - publish_dir: ./_docs/_html - publish_branch: gh-pages - enable_jekyll: false - keep_files: true - destination_dir: docs/${{ env.LANG_NAME }} - commit_message: > - Deploying documentation for ${{ env.LANG_NAME }}: https://kakadu.github.io/${{ github.event.repository.name }}/docs/${{ env.LANG_NAME }} - user_name: '${{ github.event.repository.name }}[bot]' - user_email: '${{ github.event.repository.name }}[bot]@users.noreply.github.com' - - - run: > - .github/make_doc_msg.sh \ - "${{ github.event.repository.name }}" \ - "${{ env.LANG_NAME }}" \ - _docs/percent.txt \ - text.md - - - run: cat text.md - - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc-docs - if: ${{ always() }} - with: - issue-number: ${{ env.PR_NUMBER }} - body-includes: Документация и тестовое покрытие - comment-author: Kakadu - - #- run: | - # echo "${{ steps.fc.outputs.comment-id }}" - # echo "${{ steps.fc.outputs.comment-body }}" - # echo "${{ steps.fc.outputs.comment-author }}" - # echo "${{ steps.fc.outputs.comment-created-at }}" - - # The way to remove comments changes to prevent pulling extra docker image should exist. - #- name: Delete old comment - # uses: jungwinter/comment@v1 - # if: ${{ steps.fc.outputs.comment-id != 0 }} - # with: - # type: delete - # comment_id: ${{ steps.fc.outputs.comment-id }} - # token: ${{ secrets.GITHUB_TOKEN }} - - - run: opam install yojson curly --yes - - - name: Manually remove comment '${{ steps.fc-docs.outputs.comment-id }}' with docs info - if: ${{ steps.fc-docs.outputs.comment-id != 0 }} - run: > - opam exec -- ocaml .github/add_comment.ml \ - -token ${{ secrets.GITHUB_TOKEN }} \ - -issue ${{ env.PR_NUMBER }} \ - -delete-comment ${{ steps.fc-docs.outputs.comment-id }} \ - -user Kakadu \ - -repo comp23hw - - - name: List installed OPAM packages - run: opam list - - - run: opam exec -- ocamlopt --version - - - name: Adding a comment from 'text.md' manually - run: > - opam exec -- ocaml .github/add_comment.ml \ - -file text.md \ - -token ${{ secrets.GITHUB_TOKEN }} \ - -issue ${{ env.PR_NUMBER }} \ - -repo fp2023 \ - -user Kakadu - - upload_coverage: - runs-on: ubuntu-latest - if: ${{( github.event.workflow_run.event == 'pull_request') && (github.event.workflow_run.conclusion == 'success') }} - steps: - - name: Download coverage artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: PR.yml - name: coverage - path: _coverage - - - run: | - echo "LANG_NAME=$(cat _coverage/projectname.txt)" >> $GITHUB_ENV - - - run: echo "${{ env.LANG_NAME }}" - - - run: exit 1 - if: ${{ env.LANG_NAME == '' }} - - - name: Deploy coverage - uses: peaceiris/actions-gh-pages@v3 - with: - #github_token: ${{ secrets.GITHUB_TOKEN }} # used only to publish in local repo - github_token: ${{ secrets.FP2023_UPLOAD_LINTS }} - publish_dir: ./_coverage - publish_branch: gh-pages - enable_jekyll: false - keep_files: true - destination_dir: cov/${{ env.LANG_NAME }} - commit_message: > - Deploying coverage for ${{ env.LANG_NAME }}: https://kakadu.github.io/${{ github.event.repository.name }}/cov/${{ env.LANG_NAME }} - user_name: '${{ github.event.repository.name }}[bot]' - user_email: '${{ github.event.repository.name }}[bot]@users.noreply.github.com' - - - ################################################################################################### - process_clones: - runs-on: ubuntu-latest - if: false - #if: > - # ${{ github.event.workflow_run.event == 'pull_request' && - # github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Download artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: PR.yml - name: jscpd_report - - - run: | - echo "PR_NUMBER=$(cat PR_number.txt)" >> $GITHUB_ENV - echo "LANG_NAME=$(cat projectname.txt)" >> $GITHUB_ENV - - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ env.PR_NUMBER }} - body-includes: "#### A report of looking for clones for mini language" - comment-author: github-actions[bot] - - #- name: ${{ steps.fc.outputs.comment-id }} - # run: | - # echo "${{ steps.fc.outputs.comment-body }}" - - - name: Delete old comment - uses: jungwinter/comment@v1 - if: ${{ steps.fc.outputs.comment-id != 0 }} - with: - type: delete - comment_id: ${{ steps.fc.outputs.comment-id }} - token: ${{ secrets.GITHUB_TOKEN }} - - #- name: Delete old comment - # if: ${{ steps.fc.outputs.comment-id != 0 }} - # run: | - # curl -L https://api.github.com/repos/Kakadu/fp2023/pulls/comments/${{ steps.fc.outputs.comment-id }} \ - # -X DELETE -H "Accept: application/vnd.github+json" \ - # -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - # -H "X-GitHub-Api-Version: 2022-11-28" - # I tried to remove manually but it doesn't work - # { "message": "Not Found", - # "documentation_url": "https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request" - #} - - - name: Read file contents - id: read-escaped-markdown - uses: andstor/file-reader-action@v1 - with: - path: jscpd_report.txt - - - # https://stackoverflow.com/a/7359879 - - name: Prepare text with clones report - id: render_template - shell: bash - run: | - printf "#### A report of looking for clones for mini language ${{ env.LANG_NAME }}\n\n\`\`\`\n" > template.md - cat jscpd_report.txt >> template.md - printf "\`\`\`" >> template.md - - - run: cat template.md - - # I used the following action earlier, but it pull +1 docker image - #- name: Render template - # id: render_template - # uses: chuhlomin/render-template@v1.4 - # with: - # template: .github/jscpd.template.md - # vars: | - # contents: ${{ steps.read-escaped-markdown.outputs.contents }} - - - name: Create comment - uses: peter-evans/create-or-update-comment@v3 - if: ${{ steps.read-escaped-markdown.outputs.contents != '' }} - with: - edit-mode: replace - issue-number: ${{ env.PR_NUMBER }} - body-path: template.md - - - if: ${{ steps.read-escaped-markdown.outputs.contents == '' }} - run: echo "JSPD report is empty" diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index a5a7890d5..000000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Build master - -on: - #pull_request: - # branches: - # - 'master' - push: - paths-ignore: - - 'README.md' - - 'exam.md' - branches: - - 'master' -env: - OPAMROOT: /home/user/.opam - OPAMYES: true - -jobs: - build: - defaults: - run: - shell: bash - - runs-on: ubuntu-latest - container: - image: kakadu18/ocaml:fp2023 - #options: --user user - #options: -v /__w/test-ocaml-ci-docker/test-ocaml-ci-docker:/home/user/:rw -w /home/user/ - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - #cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - cancel-in-progress: true - #${{ github.ref != 'refs/heads/main' }} - - steps: - - # Tryign to use concurrency pecification instead of this action. - #- name: Cancel Previous Runs - # uses: styfle/cancel-workflow-action@0.11.0 - # with: - # access_token: ${{ github.token }} - - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # path: /__w/test-ocaml-ci-docker/test-ocaml-ci-docker - - - run: ls -la - #- run: git log - #- run: git diff --name-only HEAD~0 HEAD~1 - ############# Detecting and compiling fp202x - # Smart link about setting environment variables - # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - - run: | - bash -x ./detect_latest.sh >> $GITHUB_ENV - echo "${{ env.latest }}" - - - name: Installing dependencies - run: cd ${{ env.latest }} && opam install . --deps-only --with-test --with-doc --yes - - - if: false - name: Checking ocamlformat - run: | - cd ${{ env.latest }} && opam exec -- dune build @fmt --profile=release - - - name: Compiling ${{ env.latest }}... - run: cd ${{ env.latest }} && opam exec -- dune build --profile=release - - - name: Running tests in ${{ env.latest }}... - run: cd ${{ env.latest }} && opam exec -- dune runtest --profile=release - - - name: Build API documentation for ${{ env.latest }}... - run: | - opam install odoc --yes - cd ${{ env.latest }} && opam exec -- dune build @doc --profile=release - - - uses: actions/checkout@v2 - with: - repository: Kakadu/zanuda - path: zanuda - - - run: opam pin add ./zanuda --no-action - - name: Installing linter - run: opam install zanuda --yes --with-doc - - - uses: reviewdog/action-setup@v1 - - - run: echo "RDJSON_DIR_PATH=_build/default/_found_lints" >> $GITHUB_ENV - - run: cd ${{ env.latest }} && mkdir -p ${{ env.RDJSON_DIR_PATH }} - - run: echo "RDJSON_FILE_PATH=${{ env.RDJSON_DIR_PATH }}/lints.rdjsonl" >> $GITHUB_ENV - - - name: Running linter in ${{ env.latest }}... - run: cd ${{ env.latest }} && opam exec -- zanuda -dir . -add-prefix ${{ env.latest }}/ -ordjsonl ${{ env.RDJSON_FILE_PATH }} - - - # github has a limit on annotations. pr-review seems not have this limitation - # Error: reviewdog: Too many results (annotations) in diff. - # You may miss some annotations due to GitHub limitation for annotation created by logging command. - # Please check GitHub Actions log console to see all results. - - # Limitation: - # - 10 warning annotations and 10 error annotations per step - # - 50 annotations per job (sum of annotations from all the steps) - # - 50 annotations per run (separate from the job annotations, these annotations aren't created by users) - -# - name: Run reviewdog check (1/5) -# if: ${{ true }} -# continue-on-error: true -# env: -# REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_TOKEN1 }} -# run: > -# cat ${{ env.latest }}/${{ env.RDJSON_FILE_PATH }} | -# sed -n '1,49p' | -# reviewdog -f=rdjsonl -filter-mode nofilter -reporter=github-pr-check - - #- name: Run reviewdog - # env: - # REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_TOKEN1 }} - # run: > - # cat ${{ env.latest }}/${{ env.RDJSON_FILE_PATH }} | - # reviewdog -f=rdjsonl -filter-mode nofilter -reporter=github-pr-review diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml new file mode 100644 index 000000000..6b3d1f89c --- /dev/null +++ b/.github/workflows/run-test.yml @@ -0,0 +1,27 @@ +name: Build & test on Linux + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + ocaml-compiler: ["4.14.x"] + + steps: + - uses: actions/checkout@v4 + + - name: Setup OCaml ${{ matrix.ocaml-compiler }} + uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + + - name: Opam dependencies + run: opam install --deps-only -t . + + - name: Build + run: opam exec -- dune build + + - name: Runtest + run: opam exec -- dune runtest diff --git a/.gitignore b/.gitignore index ea324a5c2..a0d98ef45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,31 @@ -# Mac -.DS_Store +*.annot +*.cmo +*.cma +*.cmi +*.a +*.o +*.cmx +*.cmxs +*.cmxa -# vscode -.vscode/ \ No newline at end of file +# ocamlbuild working directory +_build/ + +# ocamlbuild targets +*.byte +*.native + +# oasis generated files +setup.data +setup.log + +# Merlin configuring file for Vim and Emacs +.merlin + +# Dune generated files +*.install + +# Local OPAM switch +_opam/ + +_coverage \ No newline at end of file diff --git a/asm/.ocamlformat b/.ocamlformat similarity index 100% rename from asm/.ocamlformat rename to .ocamlformat diff --git a/C/.gitignore b/C/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/C/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/C/.ocamlformat b/C/.ocamlformat deleted file mode 100644 index 6ae158582..000000000 --- a/C/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=ocamlformat -sequence-style=terminator -max-indent=2 - diff --git a/C/C.opam b/C/C.opam deleted file mode 100644 index e49e0f64c..000000000 --- a/C/C.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "Interpreter of the C language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["st106768@student.spbu.ru"] -authors: ["Pavlushkin Dmitrii Vladimirovich"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/PavlushaSource" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "stdint" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/C/Makefile b/C/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/C/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/C/README.md b/C/README.md deleted file mode 100644 index 9ef675e63..000000000 --- a/C/README.md +++ /dev/null @@ -1,14 +0,0 @@ -### An implementaion of Lambda mini-language [WIP] - -This is a homework for functional programming course. - -**Author**: Pavlushkin Dmitrii, pavlushkin.dima1785@gmail.com - -Features done (append only): - -- noting yet - - -Features in progress (and TODOs): - -- noting yet diff --git a/C/REPL.ml b/C/REPL.ml deleted file mode 100644 index e69de29bb..000000000 diff --git a/C/demos/demoBinarySearch.ml b/C/demos/demoBinarySearch.ml deleted file mode 100644 index eb33bce83..000000000 --- a/C/demos/demoBinarySearch.ml +++ /dev/null @@ -1,37 +0,0 @@ -open C_lib - -let () = - let s = - {| - int binarySearch(int a, int *array, int n) { - int low = 0; - int high = n - 1; - int middle; - while (low <= high) { - middle = (low + high) / 2; - if (a < array[middle] || a > array[middle]) { - if (a < array[middle]) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - else { - return middle; - } - } - return -1; - } - - int main() { - int array[5] = {3, 7, 10, 23, 100}; - return binarySearch(7, array, 5); - } - |} - in - match Parser.parse s with - | Result.Ok ast -> - Format.printf "%a\n" Ast.pp_prog ast - | Error _ -> - Format.printf "Some error" diff --git a/C/demos/demoFact.ml b/C/demos/demoFact.ml deleted file mode 100644 index 7e88fd98f..000000000 --- a/C/demos/demoFact.ml +++ /dev/null @@ -1,26 +0,0 @@ -open C_lib - -let () = - let s = - {| - int factorial(int n) { - if (n >= 1) { - return n * factorial(n - 1); - } - else { - return 1; - } - } - - int main() { - int n = 5; - return factorial(n); - } - - |} - in - match Parser.parse s with - | Result.Ok ast -> - Format.printf "%a\n" Ast.pp_prog ast - | Error _ -> - Format.printf "Some error" diff --git a/C/demos/dune b/C/demos/dune deleted file mode 100644 index 042b9149a..000000000 --- a/C/demos/dune +++ /dev/null @@ -1,19 +0,0 @@ -(executable - (name demoFact) - (modules demoFact) - (public_name demoFact) - (libraries C_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoBinarySearch) - (modules demoBinarySearch) - (public_name demoBinarySearch) - (libraries C_lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to parsingTests) - (deps %{bin:demoFact} %{bin:demoBinarySearch})) diff --git a/C/demos/parsingTests.t b/C/demos/parsingTests.t deleted file mode 100644 index ea0ea3b68..000000000 --- a/C/demos/parsingTests.t +++ /dev/null @@ -1,104 +0,0 @@ - $ dune exec demoFact - (My_programm - [(Func_def ((Func_decl (ID_int, "factorial", [(Arg (ID_int, "n"))])), - (Compound - [(If_else ( - (Bin_expr (GrowOrEqual, (Var_name "n"), (Const (V_int 1)))), - (Compound - [(Return - (Bin_expr (Mul, (Var_name "n"), - (Func_call ("factorial", - [(Bin_expr (Sub, (Var_name "n"), (Const (V_int 1)) - )) - ] - )) - ))) - ]), - (Compound [(Return (Const (V_int 1)))]))) - ]) - )); - (Func_def ((Func_decl (ID_int, "main", [])), - (Compound - [(Var_decl (ID_int, "n", (Some (Expression (Const (V_int 5)))))); - (Return (Func_call ("factorial", [(Var_name "n")])))]) - )) - ]) - - $ dune exec demoBinarySearch - (My_programm - [(Func_def ( - (Func_decl (ID_int, "binarySearch", - [(Arg (ID_int, "a")); (Arg ((Pointer ID_int), "array")); - (Arg (ID_int, "n"))] - )), - (Compound - [(Var_decl (ID_int, "low", (Some (Expression (Const (V_int 0)))))); - (Var_decl (ID_int, "high", - (Some (Expression - (Bin_expr (Sub, (Var_name "n"), (Const (V_int 1)))))) - )); - (Var_decl (ID_int, "middle", None)); - (While ( - (Bin_expr (LessOrEqual, (Var_name "low"), (Var_name "high"))), - (Compound - [(Assign ((Var_name "middle"), - (Expression - (Bin_expr (Div, - (Bin_expr (Add, (Var_name "low"), - (Var_name "high"))), - (Const (V_int 2))))) - )); - (If_else ( - (Bin_expr (Or, - (Bin_expr (Less, (Var_name "a"), - (Index ((Var_name "array"), (Var_name "middle") - )) - )), - (Bin_expr (Grow, (Var_name "a"), - (Index ((Var_name "array"), (Var_name "middle") - )) - )) - )), - (Compound - [(If_else ( - (Bin_expr (Less, (Var_name "a"), - (Index ((Var_name "array"), - (Var_name "middle"))) - )), - (Compound - [(Assign ((Var_name "high"), - (Expression - (Bin_expr (Sub, (Var_name "middle"), - (Const (V_int 1))))) - )) - ]), - (Compound - [(Assign ((Var_name "low"), - (Expression - (Bin_expr (Add, (Var_name "middle"), - (Const (V_int 1))))) - )) - ]) - )) - ]), - (Compound [(Return (Var_name "middle"))]))) - ]) - )); - (Return (Unary_expr (Minus, (Const (V_int 1)))))]) - )); - (Func_def ((Func_decl (ID_int, "main", [])), - (Compound - [(Var_decl ((Array ((Some 5), ID_int)), "array", - (Some (Expression - (Array_value - [(Const (V_int 3)); (Const (V_int 7)); - (Const (V_int 10)); (Const (V_int 23)); - (Const (V_int 100))]))) - )); - (Return - (Func_call ("binarySearch", - [(Const (V_int 7)); (Var_name "array"); (Const (V_int 5))] - ))) - ]) - )) - ]) diff --git a/C/dune b/C/dune deleted file mode 100644 index cc19117e5..000000000 --- a/C/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries C.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/C/dune-project b/C/dune-project deleted file mode 100644 index 3a0a0b2e1..000000000 --- a/C/dune-project +++ /dev/null @@ -1,33 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Pavlushkin Dmitrii Vladimirovich") - -(maintainers "st106768@student.spbu.ru") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "https://github.com/PavlushaSource") - -(package - (name C) - (synopsis "Interpreter of the C language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - stdint - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - )) diff --git a/C/lib/ast.ml b/C/lib/ast.ml deleted file mode 100644 index 0f7f23960..000000000 --- a/C/lib/ast.ml +++ /dev/null @@ -1,101 +0,0 @@ -(** Copyright 2021-2023, PavlushaSource *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Stdint - -type name = string [@@deriving show {with_path= false}] - -type types = - | ID_int - | ID_int32 - | ID_int16 - | ID_int8 - | ID_uint32 - | ID_uint16 - | ID_uint8 - | ID_char - | ID_void - | ID_float - | ID_double - | Pointer of types - | Array of int option * types -[@@deriving show {with_path= false}] - -type arg = Arg of types * name [@@deriving show {with_path= false}] - -type bin_op = - | Add - | Sub - | Mul - | Div - | Mod - | Equal - | NotEqual - | Less - | LessOrEqual - | Grow - | GrowOrEqual - | Or - | And - | Lshift - | Rshift -[@@deriving show {with_path= false}] - -type un_op = - | Not (** !a *) - | Plus (** +a *) - | Minus (** -(--a) *) - | Address (** &a *) - | Dereference (** *a *) - | Pref_increment (** ++a *) - | Pref_decrement (** --a *) -[@@deriving show {with_path= false}] - -type values = - | V_int of int - | V_int32 of Int32.t - | V_int16 - | V_int8 - | V_uint32 - | V_uint16 - | V_uint8 - | V_char of char - | V_float of float - | V_null - | V_void -[@@deriving show {with_path= false}] - -type expr = - | Unary_expr of un_op * expr - | Bin_expr of bin_op * expr * expr - | Const of values - | Type of types (** sizeof(int) *) - | Func_call of name * expr list (** factorial(1, 2 + 3, 5 > 7) *) - | Var_name of name (** return *) - | Cast of types * expr (** (int) a *) - | Index of expr * expr (** a[1][2] => Index(Index(Var_name(a), 1), 2) *) - | Array_value of expr list -[@@deriving show {with_path= false}] - -type statement = - | Var_decl of types * name * statement option (** int **b[1][2]; *) - | Assign of expr * statement (** int n = b = 4*) - | Expression of expr - | Return of expr - | Compound of statement list (** { n = 4; { n = 3;...} here n = 4 } *) - | While of expr * statement - | For of statement option * expr option * expr option * statement - (** for (init?; cond?; upd?) { expr list } *) - | If of expr * statement - | If_else of expr * statement * statement - | Break - | Continue -[@@deriving show {with_path= false}] - -type prog = - | My_programm of prog list - | Func_def of prog * statement - | Func_decl of types * name * arg list - | Top_var_decl of types * name * statement option -[@@deriving show {with_path= false}] diff --git a/C/lib/dune b/C/lib/dune deleted file mode 100644 index 32d2637ea..000000000 --- a/C/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name C_lib) - (public_name C.Lib) - (modules Ast Parser) - (libraries base angstrom stdint) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_inline_test ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/C/lib/parser.ml b/C/lib/parser.ml deleted file mode 100644 index 957aa9816..000000000 --- a/C/lib/parser.ml +++ /dev/null @@ -1,673 +0,0 @@ -(** Copyright 2021-2023, PavlushaSource *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open! Base -open Ast -open Angstrom - -let pp printer parser str = - Stdlib.Format.printf "%a" printer - @@ Result.ok_or_failwith - @@ Angstrom.parse_string ~consume:Angstrom.Consume.All parser str - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init - -let rec chainr1 e op = - e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let is_keywords = function - | "while" - | "for" - | "break" - | "continue" - | "if" - | "else" - | "return" - | "char" - | "const" - | "double" - | "float" - | "int" - | "int32_t" - | "int16_t" - | "int8_t" - | "uint32_t" - | "uint16_t" - | "uint8_t" - | "void" - | "NULL" -> - true - | _ -> - false - -let is_digit = function '0' .. '9' -> true | _ -> false - -let is_whitespace = function ' ' | '\t' | '\n' | '\r' -> true | _ -> false - -let is_valid_char_id = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> - true - | _ -> - false - -let whitespace = take_while is_whitespace - -let token s = whitespace *> string s - -let parens p = token "(" *> p <* token ")" - -let brackets p = token "[" *> p <* token "]" - -let braces p = token "{" *> p <* token "}" - -let p_number = - let dot = - peek_char - >>= function Some '.' -> advance 1 >>| fun () -> true | _ -> return false - in - let* whole = whitespace *> take_while1 is_digit in - let* dot = dot in - match dot with - | false -> - return @@ V_int (int_of_string whole) - | true -> - let* part = take_while is_digit in - return @@ V_float (float_of_string (whole ^ "." ^ part)) - -let p_ident = - let is_valid_first_char = function - | 'a' .. 'z' | 'A' .. 'Z' | '_' -> - true - | _ -> - false - in - let* first_char = peek_char in - match first_char with - | Some c when is_valid_first_char c -> - let* ident = take_while is_valid_char_id in - if is_keywords ident then fail "Keyword name" else return ident - | _ -> - fail "Invalid name" - -let p_char = - whitespace *> char '\'' *> any_char <* char '\'' >>| fun char -> V_char char - -let p_arr p_elm = braces @@ sep_by (token ",") p_elm - -let p_elements_arr p_elm = p_arr p_elm >>= fun c -> return @@ Array_value c - -let p_type = - let parse_simple_type t err = - match t with - | "int" -> - return ID_int - | "int32_t" -> - return ID_int32 - | "int16_t" -> - return ID_int16 - | "int8_t" -> - return ID_int8 - | "uint32_t" -> - return ID_uint32 - | "uint16_t" -> - return ID_uint16 - | "uint8_t" -> - return ID_uint8 - | "char" -> - return ID_char - | "void" -> - return ID_void - | "float" -> - return ID_float - | "double" -> - return ID_float - | _ -> - fail @@ "Unknown type in col: " ^ Int.to_string err - in - pos - >>= fun col -> - let* t = whitespace *> take_while1 is_valid_char_id in - let* pars = parse_simple_type t col in - let* list_ptrs = many @@ token "*" in - return (List.fold ~init:pars ~f:(fun acc _ -> Pointer acc) list_ptrs) - -let pe_type = (fun t -> Type t) <$> p_type - -let emul = token "*" *> return (fun e1 e2 -> Bin_expr (Mul, e1, e2)) - -let ediv = token "/" *> return (fun e1 e2 -> Bin_expr (Div, e1, e2)) - -let emod = token "%" *> return (fun e1 e2 -> Bin_expr (Mod, e1, e2)) - -let eadd = token "+" *> return (fun e1 e2 -> Bin_expr (Add, e1, e2)) - -let esub = token "-" *> return (fun e1 e2 -> Bin_expr (Sub, e1, e2)) - -let el = token "<" *> return (fun e1 e2 -> Bin_expr (Less, e1, e2)) - -let eg = token ">" *> return (fun e1 e2 -> Bin_expr (Grow, e1, e2)) - -let elte = token "<=" *> return (fun e1 e2 -> Bin_expr (LessOrEqual, e1, e2)) - -let egte = token ">=" *> return (fun e1 e2 -> Bin_expr (GrowOrEqual, e1, e2)) - -let eeq = token "==" *> return (fun e1 e2 -> Bin_expr (Equal, e1, e2)) - -let eneq = token "!= " *> return (fun e1 e2 -> Bin_expr (NotEqual, e1, e2)) - -let eand = token "&&" *> return (fun e1 e2 -> Bin_expr (And, e1, e2)) - -let eor = token "||" *> return (fun e1 e2 -> Bin_expr (Or, e1, e2)) - -let ershft = token ">>" *> return (fun e1 e2 -> Bin_expr (Rshift, e1, e2)) - -let elshift = token "<<" *> return (fun e1 e2 -> Bin_expr (Lshift, e1, e2)) - -let p_func_call expr = - lift2 - (fun id ls -> Func_call (id, ls)) - (whitespace *> p_ident) - (token "(" *> sep_by (token ",") (expr <|> pe_type) <* token ")") - -let p_index_array expr = - let rec helper ind = - whitespace *> peek_char - >>= function - | Some '[' -> - brackets expr >>= fun e -> helper @@ Index (ind, e) - | _ -> - return ind - in - whitespace *> p_ident - >>= fun id -> - brackets expr - >>= fun e -> - whitespace *> peek_char - >>= function - | Some '[' -> - helper @@ Index (Var_name id, e) - | _ -> - return @@ Index (Var_name id, e) - -let var_name = (fun c -> Var_name c) <$> whitespace *> p_ident - -let null = token "NULL" *> (return @@ V_null) - -let p_const : expr t = p_number <|> p_char <|> null >>| fun c -> Const c - -let p_un expr = - whitespace *> peek_char_fail - >>= function - | '-' -> ( - advance 1 *> peek_char_fail - >>= function - | '-' -> - advance 1 *> expr - >>= fun e1 -> return @@ Unary_expr (Pref_decrement, e1) - | _ -> - expr >>= fun e1 -> return @@ Unary_expr (Minus, e1) ) - | '+' -> ( - advance 1 *> peek_char_fail - >>= function - | '+' -> - advance 1 *> expr - >>= fun e1 -> return @@ Unary_expr (Pref_increment, e1) - | _ -> - expr >>= fun e1 -> return @@ Unary_expr (Plus, e1) ) - | _ -> - fail "Expected '-'" - -let p_deref expr = - fix (fun deref -> - token "*" *> (parens expr <|> p_index_array expr <|> var_name <|> deref) - >>= fun exp -> return @@ Unary_expr (Dereference, exp) ) - -let p_address expr = - (fun exp -> Unary_expr (Address, exp)) - <$> token "&" *> (p_index_array expr <|> parens expr <|> var_name <|> expr) - -let p_cast expr = - lift2 (fun tp exp -> Cast (tp, exp)) (token "(" *> p_type <* token ")") expr - -let p_not expr = token "!" *> expr >>= fun c -> return @@ Unary_expr (Not, c) - -let p_expr : expr t = - fix (fun expr -> - let term = - choice - [parens expr; p_func_call expr; p_index_array expr; var_name; p_const] - in - let term = p_not term <|> term in - let term = p_cast term <|> term in - let term = p_address term <|> term in - let term = p_deref term <|> term in - let term = p_un term <|> term in - let term = chainl1 term (emul <|> emod <|> ediv) in - let term = chainl1 term (eadd <|> esub) in - let term = chainl1 term (ershft <|> elshift) in - let term = chainl1 term (elte <|> egte <|> el <|> eg <|> eeq <|> eneq) in - let term = chainr1 term eand in - let term = chainr1 term eor in - let term = fix (fun e -> term <|> p_elements_arr e) <|> term in - term ) - -let%expect_test "type parse" = - pp pp_types p_type "int32_t"; - [%expect {| - ID_int32 |}] - -let%expect_test "shift parse" = - pp pp_expr p_expr "*a >> 2 + 2"; - [%expect - {| - (Bin_expr (Rshift, (Unary_expr (Dereference, (Var_name "a"))), - (Bin_expr (Add, (Const (V_int 2)), (Const (V_int 2)))))) |}] - -let%expect_test "array value parse" = - pp pp_expr p_expr "{1, 2 + 2, 3}"; - [%expect - {| - (Array_value - [(Const (V_int 1)); - (Bin_expr (Add, (Const (V_int 2)), (Const (V_int 2)))); - (Const (V_int 3))]) |}] - -let%expect_test "fun_call test" = - pp pp_expr p_expr "malloc(n, 12) - malloc(12 - 1)"; - [%expect - {| - (Bin_expr (Sub, (Func_call ("malloc", [(Var_name "n"); (Const (V_int 12))])), - (Func_call ("malloc", - [(Bin_expr (Sub, (Const (V_int 12)), (Const (V_int 1))))])) - )) |}] - -let%expect_test "index array test" = - pp pp_expr p_expr "array[1 * 3][2 * 8]"; - [%expect - {| - (Index ( - (Index ((Var_name "array"), - (Bin_expr (Mul, (Const (V_int 1)), (Const (V_int 3)))))), - (Bin_expr (Mul, (Const (V_int 2)), (Const (V_int 8)))))) |}] - -let%expect_test "unary priority test" = - pp pp_expr p_expr "--1 + 2"; - [%expect - {| - (Bin_expr (Add, (Unary_expr (Pref_decrement, (Const (V_int 1)))), - (Const (V_int 2)))) |}] - -let%expect_test "deref priority test" = - pp pp_expr p_expr "&2 + 2"; - [%expect - {| - (Bin_expr (Add, (Unary_expr (Address, (Const (V_int 2)))), (Const (V_int 2)) - )) |}] - -let%expect_test "not priority test" = - pp pp_expr p_expr "!a + 2"; - [%expect - {| - (Bin_expr (Add, (Unary_expr (Not, (Var_name "a"))), (Const (V_int 2)))) |}] - -let%expect_test "sizeof test" = - pp pp_expr p_expr "sizeof(char)"; - [%expect {| - (Func_call ("sizeof", [(Type ID_char)])) |}] - -let%expect_test "ref priority test" = - pp pp_expr p_expr "*a + 2"; - [%expect - {| - (Bin_expr (Add, (Unary_expr (Dereference, (Var_name "a"))), (Const (V_int 2)) - )) |}] - -let%expect_test "index priority test" = - pp pp_expr p_expr "a[2] + b[3]"; - [%expect - {| - (Bin_expr (Add, (Index ((Var_name "a"), (Const (V_int 2)))), - (Index ((Var_name "b"), (Const (V_int 3)))))) |}] - -let%expect_test "logical not priority test" = - pp pp_expr p_expr "!a[2]"; - [%expect - {| - (Unary_expr (Not, (Index ((Var_name "a"), (Const (V_int 2)))))) |}] - -let%expect_test "cast priority test" = - pp pp_expr p_expr "(int) 2 + 2"; - [%expect - {| - (Bin_expr (Add, (Cast (ID_int, (Const (V_int 2)))), (Const (V_int 2)))) |}] - -let p_arg = - p_type <* whitespace >>= fun t -> p_ident >>= fun id -> return @@ Arg (t, id) - -let p_compound statements = - whitespace *> token "{" *> many (whitespace *> statements <* whitespace) - <* token "}" - >>= fun s -> whitespace *> (return @@ Compound s) - -let p_if statements = - token "if" *> parens p_expr - >>= fun cnd -> p_compound statements >>= fun cmpd -> return @@ If (cnd, cmpd) - -let p_if_else statements = - token "if" *> parens p_expr - >>= fun cnd -> - p_compound statements - >>= fun cmd_if -> - token "else" *> p_compound statements - >>= fun cmd_else -> return @@ If_else (cnd, cmd_if, cmd_else) - -let rec p_mult_assign expr1 = - token "=" *> p_expr - >>= fun expr2 -> - whitespace *> peek_char - >>= function - | Some '=' -> - p_mult_assign expr2 >>= fun expr2 -> return @@ Assign (expr1, expr2) - | Some ';' -> - advance 1 *> (return @@ Assign (expr1, Expression expr2)) - | _ -> - fail "expected ';' or '=' at the end" - -let p_var_decl = - let size_arr : int t = - pos - >>= fun col -> - brackets p_number - >>= function - | V_int x -> - return x - | _ -> - fail @@ "size of array must be integer. Error in col: " - ^ Int.to_string col - in - let p_type_array t = - fix (fun arr_type : types t -> - size_arr - >>= fun sz -> - whitespace *> peek_char - >>= function - | Some '[' -> - arr_type >>= fun t -> return @@ Array (Some sz, t) - | _ -> - return @@ Array (Some sz, t) ) - in - p_type - >>= function - | ID_void -> - fail "VOID cannot be a type for variable declaration" - | t -> ( - whitespace *> p_ident - >>= fun id -> - whitespace *> peek_char - >>= function - | Some '[' -> ( - p_type_array t - >>= fun t -> - token "=" *> p_expr - >>= fun exp1 -> - whitespace *> peek_char - >>= function - | Some ';' -> - advance 1 *> (return @@ Var_decl (t, id, Some (Expression exp1))) - | _ -> - fail "Error initialization with array" ) - | Some '=' -> ( - advance 1 *> whitespace *> p_expr - >>= fun exp1 -> - whitespace *> peek_char - >>= function - | Some ';' -> - advance 1 *> (return @@ Var_decl (t, id, Some (Expression exp1))) - | Some '=' -> - p_mult_assign exp1 - >>= fun st -> return @@ Var_decl (t, id, Some st) - | _ -> - fail "expected ';' or '=' at the end" ) - | Some ';' -> - advance 1 *> (return @@ Var_decl (t, id, None)) - | None | _ -> - fail "Error declaration" ) - -let p_return = - token "return" *> whitespace *> peek_char - >>= function - | Some ';' -> - advance 1 *> (return @@ Return (Const V_void)) - | Some _ -> - p_expr >>= fun exp -> token ";" *> (return @@ Return exp) - | _ -> - fail "Error return" - -let p_continue = token "continue" *> token ";" *> return Continue - -let p_break = token "break" *> token ";" *> return Break - -let p_while statements = - token "while" *> parens p_expr - >>= fun exp -> p_compound statements >>= fun cmd -> return @@ While (exp, cmd) - -let p_assign = - whitespace *> p_expr <* whitespace - >>= fun exp1 -> - peek_char - >>= function Some '=' -> p_mult_assign exp1 | _ -> fail "Error assign" - -let p_for statements = - token "for" *> token "(" - *> (p_var_decl <|> p_assign >>| Option.some <|> (return None <* token ";")) - >>= fun st -> - whitespace *> option None (p_expr >>| Option.some) - <* token ";" - >>= fun exp1 -> - whitespace *> option None (p_expr >>| Option.some) - <* token ")" <* whitespace - >>= fun exp2 -> - p_compound statements >>= fun cmd -> return @@ For (st, exp1, exp2, cmd) - -let p_statements = - fix (fun statements -> - choice - [ p_compound statements - ; p_if_else statements - ; p_if statements - ; p_while statements - ; p_for statements - ; p_assign - ; p_var_decl - ; p_continue - ; p_break - ; p_return ] ) - -let p_func_decl statements = - p_type - >>= fun t -> - whitespace *> p_ident <* whitespace - >>= fun id -> - token "(" *> sep_by (token ",") p_arg - <* token ")" - >>= fun argls -> - whitespace *> peek_char - >>= function - | Some '{' -> - p_compound statements - >>= fun cmd -> return @@ Func_def (Func_decl (t, id, argls), cmd) - | Some ';' -> - advance 1 >>= fun _ -> return @@ Func_decl (t, id, argls) - | _ -> - fail "ERROR func decl" - -let p_top_var = - p_var_decl - >>= function - | Var_decl (idd, tp, exp) -> - return @@ Top_var_decl (idd, tp, exp) <* whitespace - | _ -> - fail "ERROR" - -let p_programm = - whitespace *> sep_by whitespace (p_top_var <|> p_func_decl p_statements) - >>= fun prog_ls -> return @@ My_programm prog_ls - -let parse input = parse_string ~consume:All p_programm input - -let%expect_test "binary search" = - pp pp_prog p_programm - {| - int binarySearch(int a, int *array, int n) { - int low = 0; - int high = n - 1; - int middle; - while (low <= high) { - middle = (low + high) / 2; - if (a < array[middle] || a > array[middle]) { - if (a < array[middle]) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - else { - return middle; - } - } - return -1; - } - - int main() { - int array[5] = {3, 7, 10, 23, 100}; - return binarySearch(7, array, 5); - } - |}; - [%expect - {| - (My_programm - [(Func_def ( - (Func_decl (ID_int, "binarySearch", - [(Arg (ID_int, "a")); (Arg ((Pointer ID_int), "array")); - (Arg (ID_int, "n"))] - )), - (Compound - [(Var_decl (ID_int, "low", (Some (Expression (Const (V_int 0)))))); - (Var_decl (ID_int, "high", - (Some (Expression - (Bin_expr (Sub, (Var_name "n"), (Const (V_int 1)))))) - )); - (Var_decl (ID_int, "middle", None)); - (While ( - (Bin_expr (LessOrEqual, (Var_name "low"), (Var_name "high"))), - (Compound - [(Assign ((Var_name "middle"), - (Expression - (Bin_expr (Div, - (Bin_expr (Add, (Var_name "low"), - (Var_name "high"))), - (Const (V_int 2))))) - )); - (If_else ( - (Bin_expr (Or, - (Bin_expr (Less, (Var_name "a"), - (Index ((Var_name "array"), (Var_name "middle") - )) - )), - (Bin_expr (Grow, (Var_name "a"), - (Index ((Var_name "array"), (Var_name "middle") - )) - )) - )), - (Compound - [(If_else ( - (Bin_expr (Less, (Var_name "a"), - (Index ((Var_name "array"), - (Var_name "middle"))) - )), - (Compound - [(Assign ((Var_name "high"), - (Expression - (Bin_expr (Sub, (Var_name "middle"), - (Const (V_int 1))))) - )) - ]), - (Compound - [(Assign ((Var_name "low"), - (Expression - (Bin_expr (Add, (Var_name "middle"), - (Const (V_int 1))))) - )) - ]) - )) - ]), - (Compound [(Return (Var_name "middle"))]))) - ]) - )); - (Return (Unary_expr (Minus, (Const (V_int 1)))))]) - )); - (Func_def ((Func_decl (ID_int, "main", [])), - (Compound - [(Var_decl ((Array ((Some 5), ID_int)), "array", - (Some (Expression - (Array_value - [(Const (V_int 3)); (Const (V_int 7)); - (Const (V_int 10)); (Const (V_int 23)); - (Const (V_int 100))]))) - )); - (Return - (Func_call ("binarySearch", - [(Const (V_int 7)); (Var_name "array"); (Const (V_int 5))] - ))) - ]) - )) - ]) |}] - -let%expect_test "factorial" = - pp pp_prog p_programm - {| - int factorial(int n) { - if (n >= 1) { - return n * factorial(n - 1); - } - else { - return 1; - } - } - - int main() { - int n = 5; - return factorial(n); - } - - |}; - [%expect - {| - (My_programm - [(Func_def ((Func_decl (ID_int, "factorial", [(Arg (ID_int, "n"))])), - (Compound - [(If_else ( - (Bin_expr (GrowOrEqual, (Var_name "n"), (Const (V_int 1)))), - (Compound - [(Return - (Bin_expr (Mul, (Var_name "n"), - (Func_call ("factorial", - [(Bin_expr (Sub, (Var_name "n"), (Const (V_int 1)) - )) - ] - )) - ))) - ]), - (Compound [(Return (Const (V_int 1)))]))) - ]) - )); - (Func_def ((Func_decl (ID_int, "main", [])), - (Compound - [(Var_decl (ID_int, "n", (Some (Expression (Const (V_int 5)))))); - (Return (Func_call ("factorial", [(Var_name "n")])))]) - )) - ]) |}] diff --git a/C/repl.t b/C/repl.t deleted file mode 100644 index e69de29bb..000000000 diff --git a/C/COPYING b/COPYING similarity index 100% rename from C/COPYING rename to COPYING diff --git a/C/COPYING.CC0 b/COPYING.CC0 similarity index 100% rename from C/COPYING.CC0 rename to COPYING.CC0 diff --git a/C/COPYING.LESSER b/COPYING.LESSER similarity index 100% rename from C/COPYING.LESSER rename to COPYING.LESSER diff --git a/CSharpExceptions/.gitignore b/CSharpExceptions/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/CSharpExceptions/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/CSharpExceptions/.ocamlformat b/CSharpExceptions/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/CSharpExceptions/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/CSharpExceptions/COPYING b/CSharpExceptions/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/CSharpExceptions/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/CSharpExceptions/COPYING.CC0 b/CSharpExceptions/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/CSharpExceptions/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/CSharpExceptions/COPYING.LESSER b/CSharpExceptions/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/CSharpExceptions/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/CSharpExceptions/CSharpExceptions.opam b/CSharpExceptions/CSharpExceptions.opam deleted file mode 100644 index 776954509..000000000 --- a/CSharpExceptions/CSharpExceptions.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for language C# with exceptions" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Georgy Sichkar"] -authors: ["Georgy Sichkar"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/CSharpExceptions/Makefile b/CSharpExceptions/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/CSharpExceptions/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/CSharpExceptions/README.md b/CSharpExceptions/README.md deleted file mode 100644 index f3bb20c33..000000000 --- a/CSharpExceptions/README.md +++ /dev/null @@ -1,11 +0,0 @@ -### An implementaion of CSharpExceptions mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: [Georgy Sichkar](https://t.me/KoGora) - -Features done (append only): - -Features in progress (and TODOs): diff --git a/CSharpExceptions/demos/demoParse.ml b/CSharpExceptions/demos/demoParse.ml deleted file mode 100644 index 139d02da2..000000000 --- a/CSharpExceptions/demos/demoParse.ml +++ /dev/null @@ -1,10 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Csharp_Exc_Lib.Parser.parse_ast s with - | Result.Ok ast -> Format.printf "%a\n%!" Csharp_Exc_Lib.Ast.pp_tast ast - | Error _ -> Format.printf "%s |" s -;; diff --git a/CSharpExceptions/demos/dune b/CSharpExceptions/demos/dune deleted file mode 100644 index 7a7189db4..000000000 --- a/CSharpExceptions/demos/dune +++ /dev/null @@ -1,11 +0,0 @@ -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries csharp_Exc_Lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to parsingTests) - (deps ./demoParse.exe)) diff --git a/CSharpExceptions/demos/factorial.cs b/CSharpExceptions/demos/factorial.cs deleted file mode 100644 index 7196205d2..000000000 --- a/CSharpExceptions/demos/factorial.cs +++ /dev/null @@ -1,16 +0,0 @@ -class Program -{ - int Fac(int num) - { - if (num == 1) - { - return 1; - } - else - { - return num * Fac(num - 1); - } - } - - static void Main() {} -} \ No newline at end of file diff --git a/CSharpExceptions/demos/parsingTests.t b/CSharpExceptions/demos/parsingTests.t deleted file mode 100644 index 182a80051..000000000 --- a/CSharpExceptions/demos/parsingTests.t +++ /dev/null @@ -1,76 +0,0 @@ -Copyright 2021-2023, Georgy Sichkar -SPDX-License-Identifier: CC0-1.0 - - $ ./demoParse.exe << HATETESTS - > class Program - > { - > int Fac(int num) - > { - > if (num == 1) - > { - > return 1; - > } - > else - > { - > return num * Fac(num - 1); - > } - > } - > - > static void Main() - > { - > int number; - > number = 20; - > return Fac(number); - > } - > } - > HATETESTS - (Ast - [{ cl_modif = None; cl_id = (Id "Program"); parent = None; - cl_mems = - [(Method ( - { m_modif = None; m_type = (TReturn (TNot_Nullable TInt)); - m_id = (Id "Fac"); - m_args = - (Args - [(Var_decl ((TVariable (TVar (TNot_Nullable TInt))), - (Id "num"))) - ]) - }, - (Steps - [(SIf_else ( - (EBin_op (Equal, (EIdentifier (Id "num")), (EConst (VInt 1)) - )), - (Steps [(SReturn (Some (EConst (VInt 1))))]), - (Some (Steps - [(SReturn - (Some (EBin_op (Asterisk, - (EIdentifier (Id "num")), - (EMethod_invoke ( - (EIdentifier (Id "Fac")), - (Params - [(EBin_op (Minus, - (EIdentifier (Id "num")), - (EConst (VInt 1)))) - ]) - )) - )))) - ])) - )) - ]) - )); - (Main - (Steps - [(SDecl ( - (Var_decl ((TVariable (TVar (TNot_Nullable TInt))), - (Id "number"))), - None)); - (SExpr - (EBin_op (Assign, (EIdentifier (Id "number")), - (EConst (VInt 20))))); - (SReturn - (Some (EMethod_invoke ((EIdentifier (Id "Fac")), - (Params [(EIdentifier (Id "number"))]))))) - ])) - ] - } - ]) diff --git a/CSharpExceptions/dune-project b/CSharpExceptions/dune-project deleted file mode 100644 index 815c67366..000000000 --- a/CSharpExceptions/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Georgy Sichkar") - -(maintainers "Georgy Sichkar") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name CSharpExceptions) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "An interpreter for language C# with exceptions") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/CSharpExceptions/lib/ast.ml b/CSharpExceptions/lib/ast.ml deleted file mode 100644 index a95917141..000000000 --- a/CSharpExceptions/lib/ast.ml +++ /dev/null @@ -1,162 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** {2 Value types} *) - -type value_ = - | Null - | VString of string - | VInt of int - | VChar of char - | VBool of bool -[@@deriving show { with_path = false }] - -type ident = Id of string [@@deriving show { with_path = false }] - -(** {2 Declarations types} *) - -(** Variable type *) - -(** Type that can be assigne *) - -type base_type = - | TInt - | TChar - | TBool -[@@deriving show { with_path = false }] - -type nulable_type = - | TBase of base_type - | TString - | TClass of ident -[@@deriving show { with_path = false }] - -type assignable_type = - | TNot_Nullable of base_type - | TNullable of nulable_type -[@@deriving show { with_path = false }] - -type var_type = TVar of assignable_type [@@deriving show { with_path = false }] - -type meth_type = - | Void - | TReturn of assignable_type -[@@deriving show { with_path = false }] - -type type_ = - | TMethod of meth_type - | TVariable of var_type -[@@deriving show { with_path = false }] - -type access_modifier = - | MPublic - | MPrivate - | MProtected -[@@deriving show { with_path = false }] - -type method_modifier = - | MAccess of access_modifier - | MStatic -(* TODO: | Virtual *) -(* TODO: | Override *) -[@@deriving show { with_path = false }] - -type fild_modifier = FAccess of access_modifier -(* TODO:| New *) -(* TODO:| Const *) -[@@deriving show { with_path = false }] - -type bin_op = - | Asterisk (* [*] *) - | Plus (* [+] *) - | Minus (* [-] *) - | Division (* [/] *) - | Mod (* [%] *) - | Equal (* [==] *) - | NotEqual (* [!=] *) - | Less (* [<] *) - | LessOrEqual (* [+] *) - | More (* [>] *) - | MoreOrEqual (* [>=] *) - | And (* [&&] *) - | Or (* [||] *) - | Assign (* [=] *) -[@@deriving show { with_path = false }] - -type un_op = - | UMinus (* [-] *) - | UNot (* [!] *) - | New (* [new] *) -[@@deriving show { with_path = false }] - -type expr = - | EConst of value_ (* assignable values *) - (* *) - | EIdentifier of ident (* id of something e.g. class name; var name; method name *) - | EMethod_invoke of expr * params (* method(a, b, c) | Class.method(a, b, c) *) - (* *) - | EBin_op of bin_op * expr * expr - | EPoint_access of expr * expr (* access by point e.g. A.run() *) - | EUn_op of un_op * expr -(* *) -(* TODO: | Cast of assignable_type * expr *) - -and params = Params of expr list [@@deriving show { with_path = false }] - -type var_decl = Var_decl of type_ * ident [@@deriving show { with_path = false }] -type args = Args of var_decl list [@@deriving show { with_path = false }] - -type statement = - | SExpr of expr - | Steps of statement list (* sequence of actions inside {...} *) - | SIf_else of expr * statement * statement option - | SDecl of var_decl * expr option - | SReturn of expr option - | SBreak -[@@deriving show { with_path = false }] - -(* TODO:| SWhile *) -(* TODO:| SFor *) -(* TODO:| STry_catch_fin + throw...*) -(* TODO:| Switch *) -type fild_sign = - { f_modif : fild_modifier option - ; f_type : var_type - ; f_id : ident - ; f_val : expr option - } -[@@deriving show { with_path = false }] - -type method_sign = - { m_modif : method_modifier option - ; m_type : meth_type - ; m_id : ident - ; m_args : args - } -[@@deriving show { with_path = false }] - -type constructor_sign = - { con_modif : access_modifier option - ; con_id : ident - ; con_args : args - ; base_params : params option - } -[@@deriving show { with_path = false }] - -type class_member = - | Fild of fild_sign - | Main of statement - | Method of method_sign * statement (* statment - Steps *) - | Constructor of constructor_sign * statement (* statment - Steps *) -[@@deriving show { with_path = false }] - -type class_decl = - { cl_modif : access_modifier option - ; cl_id : ident - ; parent : ident option - ; cl_mems : class_member list - } -[@@deriving show { with_path = false }] - -type tast = Ast of class_decl list [@@deriving show { with_path = false }] diff --git a/CSharpExceptions/lib/dune b/CSharpExceptions/lib/dune deleted file mode 100644 index 0452c07ba..000000000 --- a/CSharpExceptions/lib/dune +++ /dev/null @@ -1,19 +0,0 @@ -(library - (name csharp_Exc_Lib) - (public_name CSharpExceptions.Lib) - (modules Ast Parser) - (libraries base angstrom str) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name pars_tests) - (modules pars_tests) - (libraries csharp_Exc_Lib) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_inline_test)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/CSharpExceptions/lib/pars_tests.ml b/CSharpExceptions/lib/pars_tests.ml deleted file mode 100644 index a6b60c368..000000000 --- a/CSharpExceptions/lib/pars_tests.ml +++ /dev/null @@ -1,368 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Csharp_Exc_Lib.Parser -open Csharp_Exc_Lib.Ast - -(* *******************-> tests for Parser and Ast <-******************* *) - -let eq_wrap ~eq ans = function - | Some x when eq x ans -> true - | _ -> false -;; - -let show_wrap form = function - | Some x -> Format.printf "%a@\n" form x - | _ -> Format.print_string "Some error during parsing\n" -;; - -let test_pars ps eq str ans = eq_wrap ~eq ans (parse_option ~p:ps str) -let print_pars ps form str = show_wrap form (parse_option ~p:ps str) - -(* ep_operation tests: *) -let test_pp_operation = print_pars ep_operation pp_expr - -let%expect_test "Operations - arithmetic" = - test_pp_operation - {|-(!(a + 2 - ( t.a.b / (a%b))*2)) + some(new myClass) + (-3)|}; - [%expect - {| - (EBin_op (Plus, - (EBin_op (Plus, - (EUn_op (UMinus, - (EUn_op (UNot, - (EBin_op (Minus, - (EBin_op (Plus, (EIdentifier (Id "a")), (EConst (VInt 2)))), - (EBin_op (Asterisk, - (EBin_op (Division, - (EPoint_access ((EIdentifier (Id "t")), - (EPoint_access ((EIdentifier (Id "a")), - (EIdentifier (Id "b")))) - )), - (EBin_op (Mod, (EIdentifier (Id "a")), - (EIdentifier (Id "b")))) - )), - (EConst (VInt 2)))) - )) - )) - )), - (EMethod_invoke ((EIdentifier (Id "some")), - (Params [(EUn_op (New, (EIdentifier (Id "myClass"))))]))) - )), - (EUn_op (UMinus, (EConst (VInt 3)))))) |}] -;; - -let%expect_test "Operations - predicates" = - test_pp_operation {|!(a > b) && (c < b) || 1 + 3 >= 1 == true != false|}; - [%expect - {| - (EBin_op (Or, - (EBin_op (And, - (EUn_op (UNot, - (EBin_op (More, (EIdentifier (Id "a")), (EIdentifier (Id "b")))))), - (EBin_op (Less, (EIdentifier (Id "c")), (EIdentifier (Id "b")))))), - (EBin_op (NotEqual, - (EBin_op (Equal, - (EBin_op (MoreOrEqual, - (EBin_op (Plus, (EConst (VInt 1)), (EConst (VInt 3)))), - (EConst (VInt 1)))), - (EConst (VBool true)))), - (EConst (VBool false)))) - )) |}] -;; - -let%expect_test "Multiple assign" = - test_pp_operation {|a = b= c|}; - [%expect - {| - (EBin_op (Assign, (EIdentifier (Id "a")), - (EBin_op (Assign, (EIdentifier (Id "b")), (EIdentifier (Id "c")))))) |}] -;; - -let%expect_test "Method invocation" = - test_pp_operation {|a.b.c (1, qwert_cl, "qwert_s", true, false)|}; - [%expect - {| - (EMethod_invoke ( - (EPoint_access ((EIdentifier (Id "a")), - (EPoint_access ((EIdentifier (Id "b")), (EIdentifier (Id "c")))))), - (Params - [(EConst (VInt 1)); (EIdentifier (Id "qwert_cl")); - (EConst (VString "qwert_s")); (EConst (VBool true)); - (EConst (VBool false))]) - )) |}] -;; - -(* ep_decl *) -let test_pp_ep_decl = print_pars ep_decl pp_statement - -let%expect_test "Declaration + assign" = - test_pp_ep_decl {|a egor = a (1+2, d , "qwe") + 100000|}; - [%expect - {| - (SDecl ( - (Var_decl ((TVariable (TVar (TNullable (TClass (Id "a"))))), (Id "egor"))), - (Some (EBin_op (Plus, - (EMethod_invoke ((EIdentifier (Id "a")), - (Params - [(EBin_op (Plus, (EConst (VInt 1)), (EConst (VInt 2)))); - (EIdentifier (Id "d")); (EConst (VString "qwe"))]) - )), - (EConst (VInt 100000))))) - )) |}] -;; - -let%expect_test "Declaration only" = - test_pp_ep_decl {|string egor|}; - [%expect - {| - (SDecl ((Var_decl ((TVariable (TVar (TNullable TString))), (Id "egor"))), - None)) |}] -;; - -(* ep_steps *) - -let test_pp_steps = print_pars ep_steps pp_statement - -let%expect_test "Body with conditions" = - test_pp_steps - {| {if (true) - { a(); - if(false) - { - e = b; - return; - } else - { - int ? exmp = 243 + 1; - } - }; ; ; ; - a(1+2 , cl) ; ; ; - if (1+ run()) - { - first(1); - } else if (true) {} - return 1+1; ; ; - }|}; - [%expect - {| - (Steps - [(SIf_else ((EConst (VBool true)), - (Steps - [(SExpr (EMethod_invoke ((EIdentifier (Id "a")), (Params [])))); - (SIf_else ((EConst (VBool false)), - (Steps - [(SExpr - (EBin_op (Assign, (EIdentifier (Id "e")), - (EIdentifier (Id "b"))))); - (SReturn None)]), - (Some (Steps - [(SDecl ( - (Var_decl ( - (TVariable (TVar (TNullable (TBase TInt)))), - (Id "exmp"))), - (Some (EBin_op (Plus, (EConst (VInt 243)), - (EConst (VInt 1))))) - )) - ])) - )) - ]), - None)); - (SExpr - (EMethod_invoke ((EIdentifier (Id "a")), - (Params - [(EBin_op (Plus, (EConst (VInt 1)), (EConst (VInt 2)))); - (EIdentifier (Id "cl"))]) - ))); - (SIf_else ( - (EBin_op (Plus, (EConst (VInt 1)), - (EMethod_invoke ((EIdentifier (Id "run")), (Params []))))), - (Steps - [(SExpr - (EMethod_invoke ((EIdentifier (Id "first")), - (Params [(EConst (VInt 1))])))) - ]), - (Some (SIf_else ((EConst (VBool true)), (Steps []), None))))); - (SReturn (Some (EBin_op (Plus, (EConst (VInt 1)), (EConst (VInt 1))))))]) - - |}] -;; - -let test_pp_fuc = print_pars ep_method_member pp_class_member - -let%expect_test "Method parsing" = - test_pp_fuc - {|static int Fac(int num) - { - if (num == 1) - { - return 1; - } - else - { - return num * Fac(num - 1); - } - }|}; - [%expect - {| - (Method ( - { m_modif = (Some MStatic); m_type = (TReturn (TNot_Nullable TInt)); - m_id = (Id "Fac"); - m_args = - (Args [(Var_decl ((TVariable (TVar (TNot_Nullable TInt))), (Id "num")))]) - }, - (Steps - [(SIf_else ( - (EBin_op (Equal, (EIdentifier (Id "num")), (EConst (VInt 1)))), - (Steps [(SReturn (Some (EConst (VInt 1))))]), - (Some (Steps - [(SReturn - (Some (EBin_op (Asterisk, (EIdentifier (Id "num")), - (EMethod_invoke ((EIdentifier (Id "Fac")), - (Params - [(EBin_op (Minus, - (EIdentifier (Id "num")), - (EConst (VInt 1)))) - ]) - )) - )))) - ])) - )) - ]) - )) |}] -;; - -let test_pp_class = print_pars ep_class pp_class_decl - -let%expect_test _ = - test_pp_class - {|class Program : Exception - { - int A1 = 0; - public MyClass A2; - static int Fac(int num) - { - if (num == 1) - { - return 1; - } - else - { - return num * Fac(num - 1); - } - } - }|}; - [%expect - {| - { cl_modif = None; cl_id = (Id "Program"); parent = (Some (Id "Exception")); - cl_mems = - [(Fild - { f_modif = None; f_type = (TVar (TNot_Nullable TInt)); - f_id = (Id "A1"); f_val = (Some (EConst (VInt 0))) }); - (Fild - { f_modif = (Some (FAccess MPublic)); - f_type = (TVar (TNullable (TClass (Id "MyClass")))); - f_id = (Id "A2"); f_val = None }); - (Method ( - { m_modif = (Some MStatic); m_type = (TReturn (TNot_Nullable TInt)); - m_id = (Id "Fac"); - m_args = - (Args - [(Var_decl ((TVariable (TVar (TNot_Nullable TInt))), (Id "num"))) - ]) - }, - (Steps - [(SIf_else ( - (EBin_op (Equal, (EIdentifier (Id "num")), (EConst (VInt 1)))), - (Steps [(SReturn (Some (EConst (VInt 1))))]), - (Some (Steps - [(SReturn - (Some (EBin_op (Asterisk, - (EIdentifier (Id "num")), - (EMethod_invoke ( - (EIdentifier (Id "Fac")), - (Params - [(EBin_op (Minus, - (EIdentifier (Id "num")), - (EConst (VInt 1)))) - ]) - )) - )))) - ])) - )) - ]) - )) - ] - } |}] -;; - -let test_pp_classes = print_pars ep_classes pp_tast - -let%expect_test _ = - test_pp_classes - {| class Program : Exception - { - int A1 = 0; - public MyClass A2; - static int Fac(int num) - { - if (num == 1) - { - return 1; - } - else - { - return num * Fac(num - 1); - } - } - } - class trueF {}|}; - [%expect - {| - (Ast - [{ cl_modif = None; cl_id = (Id "Program"); - parent = (Some (Id "Exception")); - cl_mems = - [(Fild - { f_modif = None; f_type = (TVar (TNot_Nullable TInt)); - f_id = (Id "A1"); f_val = (Some (EConst (VInt 0))) }); - (Fild - { f_modif = (Some (FAccess MPublic)); - f_type = (TVar (TNullable (TClass (Id "MyClass")))); - f_id = (Id "A2"); f_val = None }); - (Method ( - { m_modif = (Some MStatic); - m_type = (TReturn (TNot_Nullable TInt)); m_id = (Id "Fac"); - m_args = - (Args - [(Var_decl ((TVariable (TVar (TNot_Nullable TInt))), - (Id "num"))) - ]) - }, - (Steps - [(SIf_else ( - (EBin_op (Equal, (EIdentifier (Id "num")), - (EConst (VInt 1)))), - (Steps [(SReturn (Some (EConst (VInt 1))))]), - (Some (Steps - [(SReturn - (Some (EBin_op (Asterisk, - (EIdentifier (Id "num")), - (EMethod_invoke ( - (EIdentifier (Id "Fac")), - (Params - [(EBin_op (Minus, - (EIdentifier (Id "num")), - (EConst (VInt 1)))) - ]) - )) - )))) - ])) - )) - ]) - )) - ] - }; - { cl_modif = None; cl_id = (Id "trueF"); parent = None; cl_mems = [] }]) |}] -;; diff --git a/CSharpExceptions/lib/pars_tests.mli b/CSharpExceptions/lib/pars_tests.mli deleted file mode 100644 index 910669ae5..000000000 --- a/CSharpExceptions/lib/pars_tests.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom - -(* Wrappers *) -val eq_wrap : eq:('a -> 'b -> bool) -> 'b -> 'a option -> bool -val show_wrap : (Format.formatter -> 'a -> unit) -> 'a option -> unit - -(* Parsers for test *) -val test_pars : 'a t -> ('a -> 'b -> bool) -> string -> 'b -> bool -val print_pars : 'a t -> (Format.formatter -> 'a -> unit) -> string -> unit diff --git a/CSharpExceptions/lib/parser.ml b/CSharpExceptions/lib/parser.ml deleted file mode 100644 index 943f81bdf..000000000 --- a/CSharpExceptions/lib/parser.ml +++ /dev/null @@ -1,455 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) - -open Base -open Angstrom -open Ast - -let chainl0 expr un_op = un_op >>= (fun op -> expr >>| fun exp -> op exp) <|> expr - -let chainl1 expr bin_op = - let rec epars e1 = - lift2 (fun b_op e2 -> b_op e1 e2) bin_op expr >>= epars <|> return e1 - in - expr >>= fun init -> epars init -;; - -let chainr1 exp op = - fix (fun foo -> - lift2 (fun e1_op e2 -> e1_op e2) (lift2 (fun e1 bin_op -> bin_op e1) exp op) foo - <|> exp) -;; - -let is_type_as_keyword = function - | "int" | "char" | "string" | "bool" -> true - | _ -> false -;; - -(** @see - C# keywords *) -let is_keyword = function - | "if" - | "else" - | "while" - | "for" - | "break" - (* *) - | "class" - | "new" - | "return" - | "base" - (* *) - | "public" - | "private" - | "protected" - | "static" - | "override" - | "const" - (* *) - | "try" - | "catch" - | "finally" - | "when" - (* *) - | "null" - | "void" - | "true" - | "false" -> true - | tp -> is_type_as_keyword tp -;; - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let skip_spaces = take_while is_space -let skip_spaces1 = take_while1 is_space - -let is_token = function - | 'a' .. 'z' | '0' .. '9' | 'A' .. 'Z' | '_' -> true - | _ -> false -;; - -let if_value cond x = - try cond x |> fun _ -> true with - | Failure _ | Invalid_argument _ -> false -;; - -let is_int = if_value int_of_string -let is_bool = if_value bool_of_string - -let is_nullable = function - | '?' -> true - | _ -> false -;; - -let s_token = take_while1 is_token - -let read_as_token kw = - s_token - >>= function - | x when String.( = ) x kw -> return kw - | _ -> fail ("Not a " ^ kw) -;; - -let s_string = - char '\"' - *> take_till (function - | '\"' -> true - | _ -> false) - <* char '\"' - <|> fail "Not a string" -;; - -let p_string = s_string >>= fun str -> return (VString str) -let s_char = char '\'' *> any_char <* char '\'' <|> fail "Not a char" -let p_char = s_char >>= fun c -> return (VChar c) - -let p_number = - s_token - >>= fun str -> - match is_int str with - | true -> return (VInt (int_of_string str)) - | false -> fail "Not a number" -;; - -let p_bool = - s_token - >>= fun str -> - match is_bool str with - | true -> return (VBool (bool_of_string str)) - | false -> fail "Not a bool" -;; - -let p_ident = - s_token - >>= fun str -> - match not (is_keyword str) with - | true when not (Char.is_digit str.[0]) -> return (Id str) - | _ -> fail "Not an ident" -;; - -let base_type_converter = function - | "int" -> return TInt - | "char" -> return TChar - | "bool" -> return TBool - | _ -> fail "Not a keyword type (e.g. int)" -;; - -let s_keyword = - s_token - >>= fun tp -> - match is_type_as_keyword tp with - | true -> return tp - | false -> fail "Not a keyword type (e.g. int)" -;; - -let s_is_nullable = skip_spaces *> char '?' *> return true <|> return false - -let p_keyword_type = - s_keyword - >>= function - | "string" -> return (TNullable TString) - | base_type -> - s_is_nullable - >>= (function - | true -> base_type_converter base_type >>| fun x -> TNullable (TBase x) - | false -> base_type_converter base_type >>| fun x -> TNot_Nullable x) -;; - -let ( #~> ) str tp = read_as_token str *> return tp - -let p_access_modifier = - choice - ?failure_msg:(Some "Not a access modifier") - [ "public" #~> MPublic; "private" #~> MPrivate; "protected" #~> MProtected ] -;; - -let p_method_modifier = - choice - ?failure_msg:(Some "Not a method modifier") - [ "static" #~> MStatic; (p_access_modifier >>= fun x -> return (MAccess x)) ] -;; - -let p_fild_modifier = p_access_modifier >>= fun x -> return (FAccess x) -let p_kvar_type = p_keyword_type >>= fun x -> return (TVar x) - -let p_method_type = - choice - ?failure_msg:(Some "Not a method_type") - [ (p_keyword_type >>= fun x -> return (TReturn x)); "void" #~> Void ] -;; - -let ep_spaces prs = skip_spaces *> prs -let ep_parens prs = ep_spaces @@ (char '(' *> prs) <* ep_spaces @@ char ')' -let val_to_expr prs = ep_spaces prs >>| fun x -> EConst x -let expr_to_statment expr = expr >>| fun x -> SExpr x -let ep_figure_parens prs = ep_spaces @@ (char '{' *> prs) <* ep_spaces @@ char '}' -let ep_number = val_to_expr p_number -let ep_char = val_to_expr p_char -let ep_string = val_to_expr p_string -let ep_bool = val_to_expr p_bool -let ep_identifier = ep_spaces p_ident >>= fun x -> return (EIdentifier x) - -let ep_value = - choice ?failure_msg:(Some "Not a value") [ ep_bool; ep_char; ep_number; ep_string ] -;; - -let ep_dot = ep_spaces @@ (char '.' *> return (fun e1 e2 -> EPoint_access (e1, e2))) -let ep_member_ident = chainr1 ep_identifier ep_dot - -let ep_list_from_ ep_arg = - let ep_args = ep_arg <* ep_spaces @@ char ',' <|> ep_arg in - ep_parens @@ many ep_args -;; - -let ep_invoke_ meth_ident ep_arg = - ep_list_from_ ep_arg - >>= (fun exp -> return (Params exp)) - >>| fun args -> EMethod_invoke (meth_ident, args) -;; - -let ep_method_invoke_ ep_arg = ep_member_ident >>= fun id -> ep_invoke_ id ep_arg - -let ep_method_fild_ ep_arg = - ep_member_ident >>= fun id -> ep_invoke_ id ep_arg <|> return id -;; - -let ep_var_decl_ tp = skip_spaces1 *> p_ident >>| fun id -> Var_decl (TVariable tp, id) - -let ep_var_type_ = - ep_spaces - @@ choice - ?failure_msg:(Some "Not a var declaration") - [ p_kvar_type; (p_ident >>| fun cl -> TVar (TNullable (TClass cl))) ] -;; - -let ep_var_decl = - ep_spaces - @@ choice - ?failure_msg:(Some "Not a var declaration") - [ p_kvar_type; (p_ident >>| fun cl -> TVar (TNullable (TClass cl))) ] - >>= ep_var_decl_ -;; - -let ( |-> ) op tp = ep_spaces @@ (string op *> return tp) -let ( =>| ) op tp = op |-> tp >>| fun tp a -> EUn_op (tp, a) -let ( ==>| ) op tp = op |-> tp >>| fun t a b -> EBin_op (t, a, b) -let ( +^ ) = "+" ==>| Plus -let ( *^ ) = "*" ==>| Asterisk -let ( -^ ) = "-" ==>| Minus -let ( /^ ) = "/" ==>| Division -let ( %^ ) = "%" ==>| Mod -let ( ==^ ) = "==" ==>| Equal -let ( !=^ ) = "!=" ==>| NotEqual -let ( <^ ) = "<" ==>| Less -let ( <=^ ) = "<=" ==>| LessOrEqual -let ( >^ ) = ">" ==>| More -let ( >=^ ) = ">=" ==>| MoreOrEqual -let ( &&^ ) = "&&" ==>| And -let ( ||^ ) = "||" ==>| Or -let ( =^ ) = "=" ==>| Assign -let ep_un_minus = "-" =>| UMinus -let ep_not = "!" =>| UNot -let ep_new = "new" =>| New -let ( >- ) lvl ps_list = chainl0 lvl (choice ps_list) -let ( >>- ) lvl ps_list = chainl1 lvl (choice ps_list) -let ( -<< ) lvl ps_list = chainr1 lvl (choice ps_list) - -let ep_operation = - fix (fun expr -> - let lvl1 = - choice [ (* TODO: ep_cast expr ;*) ep_parens expr; ep_value; ep_method_fild_ expr ] - in - let lvl2 = lvl1 >- [ ep_un_minus; ep_new; ep_not ] in - let lvl3 = lvl2 >>- [ ( *^ ); ( /^ ); ( %^ ) ] in - let lvl4 = lvl3 >>- [ ( +^ ); ( -^ ) ] in - let lvl5 = lvl4 >>- [ ( <=^ ); ( >=^ ); ( <^ ); ( >^ ) ] in - let lvl6 = lvl5 >>- [ ( ==^ ); ( !=^ ) ] in - let lvl7 = lvl6 >>- [ ( &&^ ) ] in - let lvl8 = lvl7 >>- [ ( ||^ ) ] in - lvl8 -<< [ ( =^ ) ]) -;; - -let ep_assign = lift3 (fun ident eq ex -> eq ident ex) ep_identifier ( =^ ) ep_operation -let ep_method_invoke = ep_method_invoke_ ep_operation - -let ep_decl = - lift2 - (fun dcl e -> SDecl (dcl, e)) - ep_var_decl - (option None (ep_spaces (char '=') *> ep_operation >>| fun e -> Some e)) -;; - -let ep_keyword_ kw = ep_spaces @@ read_as_token kw -let ep_break = ep_keyword_ "break" *> return SBreak - -let ep_return = - lift2 - (fun _ ex -> SReturn ex) - (ep_keyword_ "return") - (ep_operation >>= (fun x -> return (Some x)) <|> return None) -;; - -let ep_is_ kw ~then_:ps = ep_keyword_ kw *> ps - -let ep_if_cond_ = - let p_cond = ep_parens ep_operation in - ep_is_ "if" ~then_:p_cond -;; - -let ep_else_cond_ ep_body ep_ifls = - choice - ?failure_msg:(Some "It isn't ELSE or ELSE IF") - [ ep_is_ "else" ~then_:ep_ifls; ep_is_ "else" ~then_:ep_body ] - >>= (fun else_ -> return (Some else_)) - <|> return None -;; - -let ep_if_else_ ep_body = - fix (fun if_else -> - let else_ = ep_else_cond_ ep_body if_else in - lift3 (fun cond body else_ -> SIf_else (cond, body, else_)) ep_if_cond_ ep_body else_) -;; - -let ep_brunch_loop_ ep_body = - choice ?failure_msg:(Some "It isn't IF or ...") [ ep_if_else_ ep_body ] -;; - -let ep_skip_semicolon_ = ep_spaces @@ char ';' - -let ep_semicolon1_ ps = - ps <* ep_skip_semicolon_ *> fix (fun foo -> ep_skip_semicolon_ *> foo <|> return "") -;; - -let ep_semicolon_ ps = ep_semicolon1_ ps <|> ps - -let ep_steps = - fix (fun steps -> - let step = ep_semicolon1_ in - let op_step = ep_semicolon_ in - let body_step = - choice - [ step ep_decl - ; step @@ expr_to_statment ep_method_invoke - ; step @@ expr_to_statment ep_assign - ; step ep_break - ; step ep_return - ; op_step @@ ep_brunch_loop_ steps - ] - in - ep_figure_parens @@ many body_step >>| fun bd -> Steps bd) -;; - -let ep_brunch_loop = ep_brunch_loop_ ep_steps -let ep_args_ = ep_list_from_ ep_var_decl >>= fun exp -> return (Args exp) -let ep_modifier_ p_mod = option None (ep_spaces p_mod >>= fun x -> return (Some x)) - -let ep_method_sign = - lift4 - (fun m_modif m_type m_id m_args -> { m_modif; m_type; m_id; m_args }) - (ep_modifier_ p_method_modifier) - (ep_spaces p_method_type) - (ep_spaces p_ident) - ep_args_ -;; - -let ep_constructor_sign = - let ep_base_cons = - ep_spaces @@ (char ':' *> ep_is_ "base" ~then_:(ep_list_from_ ep_operation)) - >>| fun x -> Some (Params x) - in - lift4 - (fun con_modif con_id con_args base_params -> - { con_modif; con_id; con_args; base_params }) - (ep_modifier_ p_access_modifier) - (ep_spaces p_ident) - ep_args_ - (option None ep_base_cons) -;; - -let ep_fild_sign = - let f_value = ep_spaces (char '=') *> ep_operation >>| fun x -> Some x in - lift4 - (fun f_modif f_type f_id f_val -> { f_modif; f_type; f_id; f_val }) - (ep_modifier_ p_fild_modifier) - (ep_spaces ep_var_type_) - (ep_spaces p_ident) - (option None f_value) - <* ep_spaces @@ char ';' -;; - -let maybe_main_ (m_sign : method_sign) = - match m_sign.m_id with - | Id "Main" -> true - | _ -> false -;; - -let is_main_type_ = function - | Void | TReturn (TNot_Nullable TInt) -> true - | _ -> false -;; - -let is_main_mod_ = function - | Some MStatic -> true - | _ -> false -;; - -let is_main_args_ = function - | Args x -> List.is_empty x -;; - -let is_main_ = function - | { m_modif; m_type; m_args; _ } - when is_main_mod_ m_modif && is_main_type_ m_type && is_main_args_ m_args -> true - | _ -> false -;; - -let ep_method_member = - ep_method_sign - >>= fun mt -> - lift2 (fun mt bd -> Method (mt, bd)) (return mt) ep_steps - >>= function - | Method (m, body) when maybe_main_ m -> - (match is_main_ m with - | true -> return (Main body) - | false -> fail "") - | m -> return m -;; - -let ep_constructor_member_ = - lift2 (fun con_sign body_ -> Constructor (con_sign, body_)) ep_constructor_sign ep_steps -;; - -let ep_fild_member_ = ep_fild_sign >>| fun x -> Fild x - -let ep_class_members = - let member = choice [ ep_method_member; ep_fild_member_; ep_constructor_member_ ] in - ep_figure_parens @@ many member -;; - -let ep_class = - let p_parent = ep_spaces @@ (char ':' *> skip_spaces *> p_ident) >>| fun x -> Some x in - let class_id = ep_spaces @@ ep_is_ "class" ~then_:(ep_spaces p_ident) in - lift4 - (fun cl_modif cl_id parent cl_mems -> { cl_modif; cl_id; parent; cl_mems }) - (ep_modifier_ p_access_modifier) - class_id - (option None p_parent) - ep_class_members -;; - -let ep_classes : tast t = many ep_class <* skip_spaces >>| fun cls -> Ast cls - -let parse_option str ~p = - match parse_string p ~consume:Angstrom.Consume.All str with - | Ok x -> Some x - | Error _ -> None -;; - -let parse_until_true p = parse_string p ~consume:Angstrom.Consume.Prefix -let parse_ast = parse_string ep_classes ~consume:Angstrom.Consume.All diff --git a/CSharpExceptions/lib/parser.mli b/CSharpExceptions/lib/parser.mli deleted file mode 100644 index 7e7989093..000000000 --- a/CSharpExceptions/lib/parser.mli +++ /dev/null @@ -1,46 +0,0 @@ -(** Copyright 2021-2023, Georgy Sichkar *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** {2 Modifier parsers} *) - -open Angstrom - -val p_access_modifier : Ast.access_modifier t -val p_method_modifier : Ast.method_modifier t -val p_fild_modifier : Ast.fild_modifier t - -(** {2 Assignable type parsers} *) - -val ep_number : Ast.expr t -val ep_char : Ast.expr t -val ep_string : Ast.expr t -val ep_bool : Ast.expr t -val ep_identifier : Ast.expr t -val ep_value : Ast.expr t - -(** {2 Language constructs parsers} *) - -val ep_member_ident : Ast.expr t -val ep_method_member : Ast.class_member t -val ep_var_decl : Ast.var_decl t -val ep_operation : Ast.expr t -val ep_assign : Ast.expr t -val ep_method_invoke : Ast.expr t -val ep_decl : Ast.statement t -val ep_break : Ast.statement t -val ep_return : Ast.statement t -val ep_steps : Ast.statement t -val ep_brunch_loop : Ast.statement t - -(** {2 Main parsers} *) - -val ep_class_members : Ast.class_member list t -val ep_class : Ast.class_decl t -val ep_classes : Ast.tast t - -(** [parse s] - this parser will read the string s and return the result *) -val parse_ast : string -> (Ast.tast, string) result - -val parse_until_true : 'a t -> string -> ('a, string) result -val parse_option : string -> p:'a t -> 'a option diff --git a/CSharpOOP/.gitignore b/CSharpOOP/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/CSharpOOP/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/CSharpOOP/.ocamlformat b/CSharpOOP/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/CSharpOOP/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/CSharpOOP/COPYING b/CSharpOOP/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/CSharpOOP/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/CSharpOOP/COPYING.CC0 b/CSharpOOP/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/CSharpOOP/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/CSharpOOP/COPYING.LESSER b/CSharpOOP/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/CSharpOOP/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/CSharpOOP/CSharpOOP.opam b/CSharpOOP/CSharpOOP.opam deleted file mode 100644 index dad745d60..000000000 --- a/CSharpOOP/CSharpOOP.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Julia Kononova"] -authors: ["Julia Kononova"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/CSharpOOP/Makefile b/CSharpOOP/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/CSharpOOP/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/CSharpOOP/README.md b/CSharpOOP/README.md deleted file mode 100644 index 066f1ef6a..000000000 --- a/CSharpOOP/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This is a homework for functional programming course. - -Author: [Julia Kononova](https://github.com/juliakononov) \ No newline at end of file diff --git a/CSharpOOP/REPL.ml b/CSharpOOP/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/CSharpOOP/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/CSharpOOP/demos/demoAO.ml b/CSharpOOP/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/CSharpOOP/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/CSharpOOP/demos/demoNO.ml b/CSharpOOP/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/CSharpOOP/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/CSharpOOP/demos/demoParse.ml b/CSharpOOP/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/CSharpOOP/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/CSharpOOP/demos/demo_input.txt b/CSharpOOP/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/CSharpOOP/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/CSharpOOP/demos/dune b/CSharpOOP/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/CSharpOOP/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/CSharpOOP/demos/interpretTests.t b/CSharpOOP/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/CSharpOOP/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/CSharpOOP/demos/parsingTests.t b/CSharpOOP/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/CSharpOOP/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/CSharpOOP/dune b/CSharpOOP/dune deleted file mode 100644 index c00522620..000000000 --- a/CSharpOOP/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries CSharpOOP.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/CSharpOOP/dune-project b/CSharpOOP/dune-project deleted file mode 100644 index 03f0d40df..000000000 --- a/CSharpOOP/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Julia Kononova") - -(maintainers "Julia Kononova") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name CSharpOOP) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/CSharpOOP/lib/Pprintast.ml b/CSharpOOP/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/CSharpOOP/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/CSharpOOP/lib/Pprintast.mli b/CSharpOOP/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/CSharpOOP/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/CSharpOOP/lib/Printast.ml b/CSharpOOP/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/CSharpOOP/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/CSharpOOP/lib/Printast.mli b/CSharpOOP/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/CSharpOOP/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/CSharpOOP/lib/ast.mli b/CSharpOOP/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/CSharpOOP/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/CSharpOOP/lib/dune b/CSharpOOP/lib/dune deleted file mode 100644 index 588176fe2..000000000 --- a/CSharpOOP/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name CSharpOOP.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/CSharpOOP/lib/interpret.ml b/CSharpOOP/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/CSharpOOP/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/CSharpOOP/lib/interpret.mli b/CSharpOOP/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/CSharpOOP/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/CSharpOOP/lib/lambda.ml b/CSharpOOP/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/CSharpOOP/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/CSharpOOP/lib/lambda.mli b/CSharpOOP/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/CSharpOOP/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/CSharpOOP/lib/parser.ml b/CSharpOOP/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/CSharpOOP/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/CSharpOOP/lib/parser.mli b/CSharpOOP/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/CSharpOOP/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/CSharpOOP/lib/tests.ml b/CSharpOOP/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/CSharpOOP/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/CSharpOOP/lib/utils.ml b/CSharpOOP/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/CSharpOOP/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/CSharpOOP/lib/utils.mli b/CSharpOOP/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/CSharpOOP/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/CSharpOOP/repl.t b/CSharpOOP/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/CSharpOOP/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/Cypher/.gitignore b/Cypher/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Cypher/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Cypher/.ocamlformat b/Cypher/.ocamlformat deleted file mode 100644 index b0368510d..000000000 --- a/Cypher/.ocamlformat +++ /dev/null @@ -1,3 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 \ No newline at end of file diff --git a/Cypher/Cypher.opam b/Cypher/Cypher.opam deleted file mode 100644 index 2646070fc..000000000 --- a/Cypher/Cypher.opam +++ /dev/null @@ -1,34 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "Cypher" -description: "Cypher interpreter" -maintainer: ["Arseniy Baytenov"] -authors: ["Arseniy Baytenov"] -license: "MIT" -homepage: "https://github.com/Arsene-Baitenov/fp2023" -bug-reports: "https://github.com/Arsene-Baitenov/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Cypher/LICENSE b/Cypher/LICENSE deleted file mode 100644 index 86fd15143..000000000 --- a/Cypher/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Arseniy Baytenov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/Cypher/README.md b/Cypher/README.md deleted file mode 100644 index e5631f0a7..000000000 --- a/Cypher/README.md +++ /dev/null @@ -1,23 +0,0 @@ -### An implementaion of Cypher interpreter - -This is a homework for functional programming course. - -License: MIT License - -Author: Arseniy Baytenov, arsenebaitenov@gmail.com - -Features done (append only): - -- Arithmetic expression parser - - variables and properties - - constants: `int64`, `float`, `string` - - literals: `true`, `false`, `null` - - comparison operators: `=`, `<>`, `IS NULL`, ... - - arithmetic operators: `+`, `%`, unary `-`, ... - -Features in progress (and TODOs): - -- Read-only query parser -- Write-only query parser -- Read-write query parser -- Interpreter \ No newline at end of file diff --git a/Cypher/dune b/Cypher/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/Cypher/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/Cypher/dune-project b/Cypher/dune-project deleted file mode 100644 index 9c9b3f329..000000000 --- a/Cypher/dune-project +++ /dev/null @@ -1,32 +0,0 @@ -(lang dune 3.7) - -(name Cypher) - -(generate_opam_files true) - -(cram enable) - -(license MIT) - -(authors "Arseniy Baytenov") - -(maintainers "Arseniy Baytenov") - -(bug_reports "https://github.com/Arsene-Baitenov/fp2023/issues") - -(homepage "https://github.com/Arsene-Baitenov/fp2023") - -(package - (name Cypher) - (synopsis "Cypher") - (description "Cypher interpreter") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build))) diff --git a/Cypher/lib/ast.ml b/Cypher/lib/ast.ml deleted file mode 100644 index 502378918..000000000 --- a/Cypher/lib/ast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2023 Arseniy Baytenov *) - -(** SPDX-License-Identifier: MIT *) - -type name = string [@@deriving show { with_path = false }] - -type literal = - | True - | False - | Null -[@@deriving show { with_path = false }] - -type constant = - | Float of float - | Int64 of int64 - | String of string -[@@deriving show { with_path = false }] - -type bin_op = - | Plus - | Minus - | Slash - | Asterisk - | Percent - | Caret - | AND - | OR - | XOR -[@@deriving show { with_path = false }] - -type un_op = - | Minus - | IS_NULL - | IS_NOT_NULL - | NOT -[@@deriving show { with_path = false }] - -type list_op = - | Eq - | NEq - | Less - | Greater - | LEq - | GEq -[@@deriving show { with_path = false }] - -type expression = - | Liter of literal - | Const of constant - | Var of name - | Property of name * name - | Bin_op of bin_op * expression * expression - | Un_op of un_op * expression - | List_op of expression * (list_op * expression) list -[@@deriving show { with_path = false }] diff --git a/Cypher/lib/dune b/Cypher/lib/dune deleted file mode 100644 index cc1c242e2..000000000 --- a/Cypher/lib/dune +++ /dev/null @@ -1,18 +0,0 @@ -(library - (name cypher_lib) - (public_name Cypher.Lib) - (modules Ast Parser) - (inline_tests) - (libraries ppx_show.runtime angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx))) - -(library - (name test) - (modules test) - (libraries base cypher_lib) - (preprocess - (pps ppx_expect)) - (inline_tests)) diff --git a/Cypher/lib/parser.ml b/Cypher/lib/parser.ml deleted file mode 100644 index 40aa4dea9..000000000 --- a/Cypher/lib/parser.ml +++ /dev/null @@ -1,316 +0,0 @@ -(** Copyright 2023 Arseniy Baytenov *) - -(** SPDX-License-Identifier: MIT *) - -open Angstrom -open Ast - -let kws = - [ "CREATE" - ; "MATCH" - ; "WITH" - ; "WHERE" - ; "DELETE" - ; "DETACH" - ; "MERGE" - ; "RETURN" - ; "CREATE" - ; "REMOVE" - ; "IS" - ; "NOT" - ; "NULL" - ; "AND" - ; "OR" - ; "XOR" - ; "TRUE" - ; "FALSE" - ] -;; - -let uc = String.uppercase_ascii - -let is_letter = function - | 'a' .. 'z' | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let skip_spaces p = - skip_while (function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false) - *> p -;; - -let skip_spaces_after p = - p - <* skip_while (function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false) -;; - -let check_after p cond = - p - <* (satisfy (fun c -> not @@ cond c) - <|> return '!' - >>= fun c -> if c != '!' then fail "Incorrect symbol" else return '!') -;; - -let parens p = skip_spaces (char '(') *> p <* skip_spaces (char ')') -let braces p = skip_spaces (char '{') *> p <* skip_spaces (char '}') -let sq_brackets p = skip_spaces (char '[') *> p <* skip_spaces (char ']') - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let un_chainl1 e op = - lift2 (fun e ops -> List.fold_left (fun e f -> f e) e ops) e (many op) -;; - -let un_chainr1 e op = - lift2 (fun ops e -> List.fold_right (fun f e -> f e) ops e) (many op) e -;; - -let parse p str = - match parse_string ~consume:All (skip_spaces_after p) str with - | Ok v -> v - | Error msg -> failwith msg -;; - -let name = - let name1 = - lift2 - (fun s1 s2 -> s1 ^ s2) - (take_while1 is_letter) - (take_while (fun c -> is_letter c || is_digit c || c = '_')) - >>= fun n -> if List.mem (uc n) kws then fail "Name cannot be keyword" else return n - in - let name2 = - lift3 - (fun s1 s2 s3 -> s1 ^ s2 ^ s3) - (char '`' *> return "`") - (take_while1 (( <> ) '`')) - (char '`' *> return "`") - in - name2 <|> name1 -;; - -let liter = - let ltrue = - take_while is_letter - >>= fun l -> - if uc l <> "TRUE" then fail "Literal TRUE parse fail" else return @@ Liter True - in - let lfalse = - take_while is_letter - >>= fun l -> - if uc l <> "FALSE" then fail "Literal FALSE parse fail" else return @@ Liter False - in - let lnull = - take_while is_letter - >>= fun l -> - if uc l <> "NULL" then fail "Literal NULL parse fail" else return @@ Liter Null - in - check_after - (skip_spaces @@ choice [ ltrue; lfalse; lnull ]) - (fun c -> not @@ is_digit c) -;; - -let const = - let sign = choice [ char '-' *> return "-"; string "" *> return "" ] in - let int64 = - check_after - (lift2 - (fun sign num -> Int64 (Int64.of_string (sign ^ num))) - sign - (take_while1 is_digit)) - (fun c -> not @@ is_letter c) - in - let float = - check_after - (lift4 - (fun sign int dot fract -> Float (float_of_string (sign ^ int ^ dot ^ fract))) - sign - (take_while1 is_digit) - (char '.' *> return ".") - (take_while1 is_digit)) - (fun c -> not @@ is_letter c) - in - let string = - let content_while_not c = lift (fun s -> String s) (take_while (( <> ) c)) in - let string c = char c *> content_while_not c <* char c in - choice [ string '\"'; string '\'' ] - in - skip_spaces @@ lift (fun c -> Const c) (choice [ string; float; int64 ]) -;; - -let var = skip_spaces @@ lift (fun v -> Var v) name - -let property = - skip_spaces - @@ lift2 - (fun s1 s2 -> Property (s1, s2)) - name - (skip_spaces (skip (fun c -> c = '.') *> skip_spaces name)) -;; - -let uminus = - check_after - (skip_spaces (char '-') *> return (fun e -> Un_op (Minus, e))) - (fun c -> not @@ is_digit c) -;; - -let uis_null = - check_after - (skip_spaces - (lift2 - (fun s1 s2 -> s1, s2) - (take_while is_letter) - (skip_spaces (take_while is_letter)) - >>= fun (s1, s2) -> - if (uc s1, uc s2) <> ("IS", "NULL") - then fail "IS_NULL parse fail" - else return (fun e -> Un_op (IS_NULL, e)))) - (fun c -> not @@ is_digit c) -;; - -let uis_not_null = - check_after - (skip_spaces - (lift3 - (fun s1 s2 s3 -> s1, s2, s3) - (take_while is_letter) - (skip_spaces (take_while is_letter)) - (skip_spaces (take_while is_letter)) - >>= fun (s1, s2, s3) -> - if (uc s1, uc s2, uc s3) <> ("IS", "NOT", "NULL") - then fail "IS_NOT_NULL parse fail" - else return (fun e -> Un_op (IS_NOT_NULL, e)))) - (fun c -> not @@ is_digit c) -;; - -let unot = - check_after - (skip_spaces - (take_while is_letter - >>= fun s -> - if uc s <> "NOT" then fail "NOT parse fail" else return (fun e -> Un_op (NOT, e)) - )) - (fun c -> not @@ is_digit c) -;; - -let bcaret = skip_spaces (char '^') *> return (fun e1 e2 -> Bin_op (Caret, e1, e2)) -let basterisk = skip_spaces (char '*') *> return (fun e1 e2 -> Bin_op (Asterisk, e1, e2)) -let bslash = skip_spaces (char '/') *> return (fun e1 e2 -> Bin_op (Slash, e1, e2)) -let bpercent = skip_spaces (char '%') *> return (fun e1 e2 -> Bin_op (Percent, e1, e2)) -let bplus = skip_spaces (char '+') *> return (fun e1 e2 -> Bin_op (Plus, e1, e2)) -let bminus = skip_spaces (char '-') *> return (fun e1 e2 -> Bin_op (Minus, e1, e2)) - -let band = - check_after - (skip_spaces - (take_while is_letter - >>= fun s -> - if uc s <> "AND" - then fail "AND parse fail" - else return (fun e1 e2 -> Bin_op (AND, e1, e2)))) - (fun c -> not @@ is_digit c) -;; - -let bor = - check_after - (skip_spaces - (take_while is_letter - >>= fun s -> - if uc s <> "OR" - then fail "OR parse fail" - else return (fun e1 e2 -> Bin_op (OR, e1, e2)))) - (fun c -> not @@ is_digit c) -;; - -let bxor = - check_after - (skip_spaces - (take_while is_letter - >>= fun s -> - if uc s <> "XOR" - then fail "XOR parse fail" - else return (fun e1 e2 -> Bin_op (XOR, e1, e2)))) - (fun c -> not @@ is_digit c) -;; - -let leq = - skip_spaces (char '=') - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (Eq, e) :: ls) - | _ -> List_op (e1, (Eq, e2) :: [])) -;; - -let lneq = - skip_spaces (string "<>") - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (NEq, e) :: ls) - | _ -> List_op (e1, (NEq, e2) :: [])) -;; - -let lless = - skip_spaces (char '<') - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (Less, e) :: ls) - | _ -> List_op (e1, (Less, e2) :: [])) -;; - -let lgreater = - skip_spaces (char '>') - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (Greater, e) :: ls) - | _ -> List_op (e1, (Greater, e2) :: [])) -;; - -let lleq = - skip_spaces (string "<=") - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (LEq, e) :: ls) - | _ -> List_op (e1, (LEq, e2) :: [])) -;; - -let lgeq = - skip_spaces (string ">=") - *> return (fun e1 e2 -> - match e2 with - | List_op (e, ls) -> List_op (e1, (GEq, e) :: ls) - | _ -> List_op (e1, (GEq, e2) :: [])) -;; - -let expr = - fix (fun expr -> - let factor = choice [ parens expr; const; property; var; liter ] in - let null_or_not_null = un_chainl1 factor (uis_null <|> uis_not_null) in - let minus = un_chainr1 null_or_not_null uminus in - let caret = chainl1 minus bcaret in - let asterisk_slash_percent = chainl1 caret (choice [ basterisk; bslash; bpercent ]) in - let plus_minus = chainl1 asterisk_slash_percent (bplus <|> bminus) in - let list_op = - chainr1 plus_minus (choice [ leq; lneq; lleq; lgeq; lless; lgreater ]) - in - let unot = un_chainr1 list_op unot in - let bxor = chainl1 unot bxor in - let band = chainl1 bxor band in - let bor = chainl1 band bor in - bor) -;; - -let parse_expr = parse expr diff --git a/Cypher/lib/test.ml b/Cypher/lib/test.ml deleted file mode 100644 index 08bb4be76..000000000 --- a/Cypher/lib/test.ml +++ /dev/null @@ -1,74 +0,0 @@ -(** Copyright 2023 Arseniy Baytenov *) - -(** SPDX-License-Identifier: MIT *) - -open Base -open Cypher_lib.Ast -open Cypher_lib.Parser - -let parse_and_print s = Stdlib.Format.printf "%a" pp_expression (parse_expr s) - -let%expect_test "Simple expr" = - parse_and_print {| 120.607 + 400 / 10 ^ 5 |}; - [%expect - {| - (Bin_op (Plus, (Const (Float 120.607)), - (Bin_op (Slash, (Const (Int64 400L)), - (Bin_op (Caret, (Const (Int64 10L)), (Const (Int64 5L)))))) - )) |}] -;; - -let%expect_test "Simple expr with unary minus" = - parse_and_print {|- 120.607 + -400 / 10 ^ -x |}; - [%expect - {| - (Bin_op (Plus, (Un_op (Minus, (Const (Float 120.607)))), - (Bin_op (Slash, (Const (Int64 -400L)), - (Bin_op (Caret, (Const (Int64 10L)), (Un_op (Minus, (Var "x"))))))) - )) |}] -;; - -let%expect_test "Multiple sequential comparison operators" = - parse_and_print {| 1+-1 = 0 <> 10 >= 5*1 <= 5/1 > - -4 |}; - [%expect - {| - (List_op ((Bin_op (Plus, (Const (Int64 1L)), (Const (Int64 -1L)))), - [(Eq, (Const (Int64 0L))); (NEq, (Const (Int64 10L))); - (GEq, (Bin_op (Asterisk, (Const (Int64 5L)), (Const (Int64 1L))))); - (LEq, (Bin_op (Slash, (Const (Int64 5L)), (Const (Int64 1L))))); - (Greater, (Un_op (Minus, (Const (Int64 -4L)))))] - )) |}] -;; - -let%expect_test "Null check operators" = - parse_and_print {| 4 = (4 + a is null IS NOT NULL) is null |}; - [%expect - {| - (List_op ((Const (Int64 4L)), - [(Eq, - (Un_op (IS_NULL, - (Bin_op (Plus, (Const (Int64 4L)), - (Un_op (IS_NOT_NULL, (Un_op (IS_NULL, (Var "a"))))))) - ))) - ] - )) |}] -;; - -let%expect_test "Boolean oparators and literals" = - parse_and_print - {| not 1 = 1 or 4 = a + 23.0 and false xor not true or "Hello" = a + "llo" |}; - [%expect - {| - (Bin_op (OR, - (Bin_op (OR, - (Un_op (NOT, (List_op ((Const (Int64 1L)), [(Eq, (Const (Int64 1L)))])) - )), - (Bin_op (AND, - (List_op ((Const (Int64 4L)), - [(Eq, (Bin_op (Plus, (Var "a"), (Const (Float 23.)))))])), - (Bin_op (XOR, (Liter False), (Un_op (NOT, (Liter True))))))) - )), - (List_op ((Const (String "Hello")), - [(Eq, (Bin_op (Plus, (Var "a"), (Const (String "llo")))))])) - )) |}] -;; diff --git a/DRozhkov/.gitignore b/DRozhkov/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/DRozhkov/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/DRozhkov/.ocamlformat b/DRozhkov/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/DRozhkov/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/DRozhkov/COPYING b/DRozhkov/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/DRozhkov/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/DRozhkov/COPYING.CC0 b/DRozhkov/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/DRozhkov/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/DRozhkov/COPYING.LESSER b/DRozhkov/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/DRozhkov/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/DRozhkov/DONT_REMOVE_THIS_DIRECTORY.md b/DRozhkov/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/DRozhkov/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/DRozhkov/DRozhkov.opam b/DRozhkov/DRozhkov.opam deleted file mode 100644 index f12e07891..000000000 --- a/DRozhkov/DRozhkov.opam +++ /dev/null @@ -1,33 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "MiniML" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -authors: ["Aleksandr Rozhkov"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/DRozhkov/Makefile b/DRozhkov/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/DRozhkov/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/DRozhkov/README.md b/DRozhkov/README.md deleted file mode 100644 index 555826255..000000000 --- a/DRozhkov/README.md +++ /dev/null @@ -1,96 +0,0 @@ -### An implementaion of Scheme delim/cc - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Rozhkov Aleksandr, alex24844@yandex.ru - -Features done (append only): - --Nothing - -Features in progress (and TODOs): - -- Parser -- interpreter of non-recursive functions -- Interpreter of recursive functions is not yet ready - - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/DRozhkov/demos/demo_fact.ml b/DRozhkov/demos/demo_fact.ml deleted file mode 100644 index bd2fe948c..000000000 --- a/DRozhkov/demos/demo_fact.ml +++ /dev/null @@ -1,13 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) -open DRozhkov_lib.Ast - -open DRozhkov_lib.Parser - -let () = - let test = "let rec fact x = if x = 0 then 1 else x * fact (x - 1)" in - match parser test with - | Result.Ok res -> Format.printf "%a\n" pp_expression res - | _ -> Format.printf "WTF????????" -;; diff --git a/DRozhkov/demos/dune b/DRozhkov/demos/dune deleted file mode 100644 index e7faaa9de..000000000 --- a/DRozhkov/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demo_fact) - (modules demo_fact) - (public_name demo_fact) - (libraries DRozhkov.Lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demo_fact})) diff --git a/DRozhkov/demos/test.t b/DRozhkov/demos/test.t deleted file mode 100644 index fb08353a7..000000000 --- a/DRozhkov/demos/test.t +++ /dev/null @@ -1,11 +0,0 @@ - $ dune exec demo_fact - Let - (Rec, "fact", - Fun - ("x", - IfThenElse - (Binop (Eq, Var ("x"), Const (Intenger (0))), Const (Intenger (1)), - Binop - (Mul, Var ("x"), - App (Var ("fact"), Binop (Sub, Var ("x"), Const (Intenger (1))))))), - Empty) diff --git a/DRozhkov/dune b/DRozhkov/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/DRozhkov/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/DRozhkov/dune-project b/DRozhkov/dune-project deleted file mode 100644 index 954d98bcb..000000000 --- a/DRozhkov/dune-project +++ /dev/null @@ -1,30 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Aleksandr Rozhkov") - -(homepage "FIXME Homepage") - -(package - (name DRozhkov) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "MiniML") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/DRozhkov/lib/ast.ml b/DRozhkov/lib/ast.ml deleted file mode 100644 index de4d6c66e..000000000 --- a/DRozhkov/lib/ast.ml +++ /dev/null @@ -1,37 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type id = string [@@deriving show { with_path = false }] - -type const = - | Intenger of int - | Float of float - | Bool of bool - | Char of char -[@@deriving show { with_path = false }] - -type bin_op = - | Add - | Sub - | Mul - | Div - | Eq - | Neq -[@@deriving show { with_path = false }] - -type expression = - | Empty - | Var of id - | Const of const - | IfThenElse of expression * expression * expression - | Binop of bin_op * expression * expression - | List of expression list - | Fun of id * expression - | App of expression * expression - | Let of fun_rec * id * expression * expression -[@@deriving show { with_path = false }] - -and fun_rec = - | Rec - | NoRec diff --git a/DRozhkov/lib/dune b/DRozhkov/lib/dune deleted file mode 100644 index fb21edbc0..000000000 --- a/DRozhkov/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name DRozhkov_lib) - (public_name DRozhkov.Lib) - (modules Parser Ast) - (inline_tests) - (preprocess - (pps ppx_show ppx_expect ppx_deriving.eq)) - (libraries ppx_show.runtime base angstrom) - (instrumentation - (backend bisect_ppx))) diff --git a/DRozhkov/lib/parser.ml b/DRozhkov/lib/parser.ml deleted file mode 100644 index 2b373c4fd..000000000 --- a/DRozhkov/lib/parser.ml +++ /dev/null @@ -1,181 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Base -open Ast - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_whitespace = function - | ' ' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let digit_c = - let is_digit = function - | '0' .. '9' -> true - | _ -> false - in - satisfy is_digit -;; - -let l_low = function - | 'a' .. 'z' | '_' -> true - | _ -> false -;; - -let l_up = function - | 'A' .. 'Z' | '_' -> true - | _ -> false -;; - -let variable = function - | 'a' .. 'z' | '_' -> true - | _ -> false -;; - -let letter = function - | 'A' .. 'Z' | 'a' .. 'z' -> true - | _ -> false -;; - -let spaces = skip_while is_space -let skip_whitespace = take_while is_whitespace -let skip_whitespace1 = take_while1 is_whitespace -let token s = skip_whitespace *> string s -let ptoken p = spaces *> p -let lp = token "(" -let rp = token ")" -let add = token "+" *> return Add -let sub = token "-" *> return Sub -let mul = token "*" *> return Mul -let div = token "/" *> return Div -let high_pr_op = skip_whitespace *> mul <|> div <* skip_whitespace -let low_pr_op = skip_whitespace *> add <|> sub <* skip_whitespace -let peq = token "=" *> return Eq -let pneq = token "<>" *> return Neq -let parens p = char '(' *> p <* char ')' - -let is_syntax = function - | "let" - | "open" - | "if" - | "else" - | "fun" - | "function" - | "then" - | "rec" - | "true" - | "false" - | "match" - | "with" - | "object" - | "end" -> true - | _ -> false -;; - -let if_then_else elem = - ptoken - @@ lift3 - (fun iff thenn elsee -> IfThenElse (iff, thenn, elsee)) - (token "if" *> elem) - (token "then" *> elem) - (token "else" *> elem <|> return Empty) -;; - -let sign = - peek_char - >>= function - | Some '-' -> advance 1 >>| fun () -> "-" - | Some '+' -> advance 1 >>| fun () -> "+" - | Some c when is_digit c -> return "+" - | _ -> fail "Sign or digit expected" -;; - -let dot = - peek_char - >>= function - | Some '.' -> advance 1 >>| fun () -> true - | _ -> return false -;; - -let number = - skip_whitespace *> sign - >>= fun sign -> - take_while1 is_digit - >>= fun whole -> - dot - >>= function - | false -> return (Const (Intenger (int_of_string (sign ^ whole)))) - | true -> - take_while1 is_digit - >>= fun part -> return (Const (Float (float_of_string (sign ^ whole ^ "." ^ part)))) -;; - -let bool_pars = - ptoken - @@ choice - [ token "true" *> return true; token "false" *> return false; fail "Not boolean" ] - >>| fun x -> Const (Bool x) -;; - -let ident = - skip_whitespace *> peek_char - >>= function - | Some x when l_low x -> - take_while l_low - >>= fun a -> if is_syntax a then fail "Reserved identifier" else return a - | _ -> fail "Invalid first char" -;; - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let let_pars pexpr = - let rec fun_pars pexpr = - ident >>= fun id -> fun_pars pexpr <|> token "=" *> pexpr >>| fun e -> Fun (id, e) - in - token "let" - *> lift4 - (fun r id e1 e2 -> Let (r, id, e1, e2)) - (token "rec" *> return Rec <|> return NoRec) - (token "()" <|> ident) - (token "=" *> pexpr <|> fun_pars pexpr) - (token "in" *> pexpr <|> return Empty) -;; - -let pebinop chain1 e pbinop = chain1 e (pbinop >>| fun op l r -> Binop (op, l, r)) -let plbinop = pebinop chainl1 -let var_pars = ident >>= fun x -> return (Ast.Var x) -let const_pars = choice [ bool_pars; number ] - -let pexpr = - fix (fun parseExpression -> - let atom = choice [ parens parseExpression; const_pars; var_pars ] in - let apply = - lift2 - (fun f args -> List.fold_left ~f:(fun f arg -> App (f, arg)) ~init:f args) - atom - (many (char ' ' *> ptoken atom)) - in - let multiplyDivide = plbinop apply high_pr_op in - let addSubtract = plbinop multiplyDivide low_pr_op in - let equalNotEqual = plbinop addSubtract (peq <|> pneq) in - let letParser = let_pars parseExpression in - let ifParser = if_then_else parseExpression in - choice [ letParser; ifParser; equalNotEqual ]) -;; - -let parser = parse_string ~consume:Consume.All (pexpr <* spaces) diff --git a/DSyresenkov/.gitignore b/DSyresenkov/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/DSyresenkov/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/DSyresenkov/.ocamlformat b/DSyresenkov/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/DSyresenkov/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/DSyresenkov/COPYING b/DSyresenkov/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/DSyresenkov/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/DSyresenkov/COPYING.CC0 b/DSyresenkov/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/DSyresenkov/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/DSyresenkov/COPYING.LESSER b/DSyresenkov/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/DSyresenkov/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/DSyresenkov/DONT_REMOVE_THIS_DIRECTORY.md b/DSyresenkov/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/DSyresenkov/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/DSyresenkov/DSyresenkov.opam b/DSyresenkov/DSyresenkov.opam deleted file mode 100644 index 7957f84e8..000000000 --- a/DSyresenkov/DSyresenkov.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "MiniML interpreter" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Ilya Syresenkov"] -authors: ["Ilya Syresenkov"] -license: "LGPL-3.0-or-later" -homepage: "github.com/Kakadu/fp2023" -bug-reports: "Write bug reports in Github issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/DSyresenkov/Makefile b/DSyresenkov/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/DSyresenkov/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/DSyresenkov/README.md b/DSyresenkov/README.md deleted file mode 100644 index 003495bb9..000000000 --- a/DSyresenkov/README.md +++ /dev/null @@ -1,13 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Ilya Syresenkov, ilya.syresenkov.04@gmail.com - -Features done (append only): - -- Factorial Parser - -Features in progress (and TODOs): diff --git a/DSyresenkov/demos/demoFact.ml b/DSyresenkov/demos/demoFact.ml deleted file mode 100644 index 0e3f2f51c..000000000 --- a/DSyresenkov/demos/demoFact.ml +++ /dev/null @@ -1,8 +0,0 @@ -open Miniml_lib - -let () = - let input = {| let rec fib x = if x = 1 then x else x * fib (x - 1) |} in - match Parser.parse input with - | Result.Ok res -> Format.printf "%a\n" Ast.pp_expr res - | _ -> Format.printf "Error" -;; diff --git a/DSyresenkov/demos/demoFact.t b/DSyresenkov/demos/demoFact.t deleted file mode 100644 index fb9bdd1ba..000000000 --- a/DSyresenkov/demos/demoFact.t +++ /dev/null @@ -1,12 +0,0 @@ - $ dune exec demoFact - (ELet (Rec, "fib", - (EFun ("x", - (EBranch ((EBinop (Eq, (EVar "x"), (EConst (CInt 1)))), (EVar "x"), - (EBinop (Mul, (EVar "x"), - (EApp ((EVar "fib"), - (EBinop (Sub, (EVar "x"), (EConst (CInt 1)))))) - )) - )) - )), - EUnit)) -x diff --git a/DSyresenkov/demos/dune b/DSyresenkov/demos/dune deleted file mode 100644 index 34e09b008..000000000 --- a/DSyresenkov/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demoFact) - (modules demoFact) - (public_name demoFact) - (libraries miniml_lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demoFact})) diff --git a/DSyresenkov/dune b/DSyresenkov/dune deleted file mode 100644 index de99b7354..000000000 --- a/DSyresenkov/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -; (executable -; (name REPL) -; (public_name REPL) -; (modules REPL) -; (libraries DSyresenkov.Lib stdio)) - -; (cram -; (deps ./REPL.exe %{bin:REPL})) diff --git a/DSyresenkov/dune-project b/DSyresenkov/dune-project deleted file mode 100644 index 0ebea542d..000000000 --- a/DSyresenkov/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Ilya Syresenkov") - -(maintainers "Ilya Syresenkov") - -(bug_reports "Write bug reports in Github issues") - -(homepage "github.com/Kakadu/fp2023") - -(package - (name DSyresenkov) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "MiniML interpreter") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/DSyresenkov/lib/ast.ml b/DSyresenkov/lib/ast.ml deleted file mode 100644 index e4e8c71c0..000000000 --- a/DSyresenkov/lib/ast.ml +++ /dev/null @@ -1,53 +0,0 @@ -(** Copyright 2021-2023, Kakadu, Ilya Syresenkov and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* - TODO: - 1. Implenent standart IO funtions -*) - -(** Identifiers for variables and functions names *) -type id = string [@@deriving show { with_path = false }] - -(** Binary operators *) -type binop = - | Add (** + *) - | Sub (** - *) - | Div (** / *) - | Mul (** * *) - | Eq (** = *) - | Neq (** <> *) -[@@deriving show { with_path = false }] - -type const = - | CInt of int (** Integers 1, 2, ... *) - | CBool of bool (** Boolean true or false *) -[@@deriving show { with_path = false }] - -type pattern = - | PWild (** | _ -> ... *) - | PConst of const (** | const -> ... *) - | PVar of id (** | varname -> ... *) - | PCons of pattern * pattern (** | p1 :: p2 -> ... *) - | POr of pattern * pattern (** | p1 | p2 | p3 -> ... *) -[@@deriving show { with_path = false }] - -type is_rec = - | Rec (** Recursive functions can call themselves in their body *) - | NonRec -[@@deriving show { with_path = false }] - -type expr = - | EUnit (** Empty expression *) - | EConst of const (** Consts *) - | EVar of id (** Variables with their names *) - | EBinop of binop * expr * expr (** e1 binop e2 *) - | ETuple of expr list (** Tuples of 2 or more elements, separeted by ',' *) - | EList of expr list (** Lists [1; 2; 3], ...*) - | EBranch of expr * expr * expr (** if [cond] then [a] else [b] *) - | EMatch of expr * (pattern * expr) list (** match [x] with | [p1] -> [e1] | ... *) - | ELet of is_rec * id * expr * expr (** let rec f *) - | EFun of id * expr (** Anonymous function *) - | EApp of expr * expr (** Application f x *) -[@@deriving show { with_path = false }] diff --git a/DSyresenkov/lib/dune b/DSyresenkov/lib/dune deleted file mode 100644 index 0b4b5bbc3..000000000 --- a/DSyresenkov/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name miniml_lib) - (public_name DSyresenkov.Lib) - (modules Ast Parser) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) - -(library - (name tests) - (modules tests) - (libraries miniml_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/DSyresenkov/lib/parser.ml b/DSyresenkov/lib/parser.ml deleted file mode 100644 index 4835c2b35..000000000 --- a/DSyresenkov/lib/parser.ml +++ /dev/null @@ -1,152 +0,0 @@ -(** Copyright 2021-2023, Kakadu, Ilya Syresenkov and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* let rec fac x = if x = 1 then x else x * (fac x) *) - -(* - Todo: - 1. Implement signed int parse - 2. Think about type annotations support - 3. Implement match parsing - 4. Think about supporting list a :: b syntax - 5. Add tuples and lists parsers - 6. Add comments parser -*) - -open Angstrom -open Base -open Ast - -let pp printer parser str = - Stdlib.Format.printf "%a" printer - @@ Result.ok_or_failwith - @@ parse_string ~consume:Consume.All parser str -;; - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_uppercase = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_lowercase = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_letter x = is_lowercase x || is_uppercase x - -(* Not all keywords are forbidden *) -let is_keyword = function - | "let" - | "rec" - | "if" - | "then" - | "else" - | "true" - | "false" - | "match" - | "with" - | "in" - | "fun" - | "type" - | "int" - | "string" - | "bool" -> true - | _ -> false -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let pspaces = skip_while is_space -let ptoken p = pspaces *> p -let pstoken s = pspaces *> Angstrom.string s -let pparens p = pstoken "(" *> p <* pstoken ")" - -let pid = - let pfirst = - satisfy (fun ch -> is_letter ch || Char.equal ch '_') >>| fun ch -> Char.escaped ch - in - let plast = take_while (fun ch -> is_letter ch || is_digit ch || Char.equal ch '_') in - ptoken @@ lift2 (fun x y -> x ^ y) pfirst plast - >>= fun s -> if is_keyword s then fail "Keyword identifiers are forbidden" else return s -;; - -let pint = ptoken @@ take_while1 is_digit >>| fun x -> EConst (CInt (int_of_string x)) - -let pbool = - ptoken - @@ choice - [ pstoken "true" *> return true - ; pstoken "false" *> return false - ; fail "Failed to parse boolean" - ] - >>| fun x -> EConst (CBool x) -;; - -let pconst = choice [ pint; pbool ] -let pvar = pid >>| fun e -> EVar e - -let plet pexpr = - let rec pbody pexpr = - pid >>= fun id -> pbody pexpr <|> pstoken "=" *> pexpr >>| fun e -> EFun (id, e) - in - pstoken "let" - *> lift4 - (fun r id e1 e2 -> ELet (r, id, e1, e2)) - (pstoken "rec" *> return Rec <|> return NonRec) - (pstoken "()" <|> pid) - (pstoken "=" *> pexpr <|> pbody pexpr) - (pstoken "in" *> pexpr <|> return EUnit) -;; - -let pbranch pexpr = - ptoken - @@ lift3 - (fun cond t f -> EBranch (cond, t, f)) - (pstoken "if" *> pexpr) - (pstoken "then" *> pexpr) - (pstoken "else" *> pexpr <|> return EUnit) -;; - -let pebinop chain1 e pbinop = chain1 e (pbinop >>| fun op e1 e2 -> EBinop (op, e1, e2)) -let plbinop = pebinop chainl1 -let padd = pstoken "+" *> return Add -let psub = pstoken "-" *> return Sub -let pmul = pstoken "*" *> return Mul -let pdiv = pstoken "/" *> return Div -let peq = pstoken "=" *> return Eq -let pneq = pstoken "<>" *> return Neq - -let pexpr = - fix - @@ fun pexpr -> - let pe = choice [ pparens pexpr; pconst; pvar ] in - let pe = - lift2 - (fun f args -> List.fold_left ~f:(fun f arg -> EApp (f, arg)) ~init:f args) - pe - (many (char ' ' *> ptoken pe)) - in - let pe = plbinop pe (pmul <|> pdiv) in - let pe = plbinop pe (padd <|> psub) in - let pe = plbinop pe (peq <|> pneq) in - choice [ plet pexpr; pbranch pexpr; pe ] -;; - -let parse = parse_string ~consume:Consume.All (pexpr <* pspaces) diff --git a/DSyresenkov/lib/parser.mli b/DSyresenkov/lib/parser.mli deleted file mode 100644 index 29f02e2fb..000000000 --- a/DSyresenkov/lib/parser.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2023, Ilya Syresenkov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* let rec fac x = if x = 1 then x else x * (fac x) *) - -open Ast - -val parse : string -> (expr, string) result diff --git a/DSyresenkov/lib/tests.ml b/DSyresenkov/lib/tests.ml deleted file mode 100644 index 973b28749..000000000 --- a/DSyresenkov/lib/tests.ml +++ /dev/null @@ -1,19 +0,0 @@ -(** Copyright 2021-2023, Kakadu, Ilya Syresenkov and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* - TODO: - 1. Add pretty print -*) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) diff --git a/FSharpActivePatterns/.gitignore b/FSharpActivePatterns/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/FSharpActivePatterns/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/FSharpActivePatterns/.ocamlformat b/FSharpActivePatterns/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/FSharpActivePatterns/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/FSharpActivePatterns/COPYING b/FSharpActivePatterns/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/FSharpActivePatterns/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/FSharpActivePatterns/COPYING.CC0 b/FSharpActivePatterns/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/FSharpActivePatterns/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/FSharpActivePatterns/COPYING.LESSER b/FSharpActivePatterns/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/FSharpActivePatterns/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/FSharpActivePatterns/DONT_REMOVE_THIS_DIRECTORY.md b/FSharpActivePatterns/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/FSharpActivePatterns/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/FSharpActivePatterns/FSharpActivePatterns.opam b/FSharpActivePatterns/FSharpActivePatterns.opam deleted file mode 100644 index 66511a186..000000000 --- a/FSharpActivePatterns/FSharpActivePatterns.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for FSharp" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["https://github.com/YazoonDinalt"] -authors: ["Vitaliy Dyachkov"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/YazoonDinalt/fp2023" -bug-reports: "https://github.com/YazoonDinalt/fp2023" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/FSharpActivePatterns/Makefile b/FSharpActivePatterns/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/FSharpActivePatterns/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/FSharpActivePatterns/README.md b/FSharpActivePatterns/README.md deleted file mode 100644 index 1730715e1..000000000 --- a/FSharpActivePatterns/README.md +++ /dev/null @@ -1,93 +0,0 @@ -### An implementaion of F# Active Patterns - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vitaliy Dyachkov, vitaliy.dyach@gmail.com - -Functions performed: -- Nothing - -Features under development: -- Parser -- Interpreter of non-recursive functions -- Ability to describe and use active patterns - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/FSharpActivePatterns/dune b/FSharpActivePatterns/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/FSharpActivePatterns/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/FSharpActivePatterns/dune-project b/FSharpActivePatterns/dune-project deleted file mode 100644 index 8892950a9..000000000 --- a/FSharpActivePatterns/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Vitaliy Dyachkov") - -(maintainers "https://github.com/YazoonDinalt") - -(bug_reports "https://github.com/YazoonDinalt/fp2023") - -(homepage "https://github.com/YazoonDinalt/fp2023") - -(package - (name FSharpActivePatterns) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "An interpreter for FSharp") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/FSharpActivePatterns/lib/ast.ml b/FSharpActivePatterns/lib/ast.ml deleted file mode 100644 index c2c5368ff..000000000 --- a/FSharpActivePatterns/lib/ast.ml +++ /dev/null @@ -1,48 +0,0 @@ -(** Copyright 2021-2023, Vitaliy Dyachkov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string [@@deriving show { with_path = false }] - -type const = - | CBool of bool (* true *) - | CInt of int (* 42 *) - | CString of string (* "string" *) -[@@deriving show { with_path = false }] - -type bin_op = - | Add (* + *) - | Sub (* - *) - | Mul (* * *) - | Div (* / *) - | Mod (* % *) - | Less (* < *) - | LEq (** <= *) - | Gre (* > *) - | GEq (** >= *) - | Eq (* = *) - | NEq (* <> *) - | And (* && *) - | Or (* || *) -[@@deriving show { with_path = false }] - -type pattern = - | Wild (* _ *) - | Const of const - | Var of name - | Tuple of pattern list (* a, b *) - | List of pattern list (** [1;2;3] *) (* Will bite during interpreter implementation *) -[@@deriving show { with_path = false }] - -type expr = - | ConstExpr of const - | VarExpr of name - | ListExpr of expr list - | TupleExpr of expr list - | BinExpr of bin_op * expr * expr - | IfExpr of expr * expr * expr - | LetExpr of name * expr - | LetRecExpr of name * expr - | AppExpr of expr * expr - | FunExpr of pattern * expr -[@@deriving show { with_path = false }] diff --git a/FSharpActivePatterns/lib/dune b/FSharpActivePatterns/lib/dune deleted file mode 100644 index 82646ea41..000000000 --- a/FSharpActivePatterns/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name FSharpActivePatterns_lib) - (public_name FSharpActivePatterns.Lib) - (modules Ast Parser) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/FSharpActivePatterns/lib/parser.ml b/FSharpActivePatterns/lib/parser.ml deleted file mode 100644 index 634fa2f83..000000000 --- a/FSharpActivePatterns/lib/parser.ml +++ /dev/null @@ -1,546 +0,0 @@ -(** Copyright 2021-2023, Vitaliy Dyachkov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Ast -open Base -module Format = Caml.Format - -(* start parse func *) - -let start_parsing parser string = parse_string ~consume:All parser string - -(* base *) -let is_lchar = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_bchar = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_keyword = function - | "let" - | "rec" - | "fun" - | "function" - | "if" - | "then" - | "else" - | "true" - | "false" - | "match" - | "with" -> true - | _ -> false -;; - -let is_whitespace = function - | ' ' | '\n' | '\t' | '\r' -> true - | _ -> false -;; - -let is_var_symbol = function - | c -> is_lchar c || is_bchar c || is_digit c || Char.equal c '_' -;; - -let is_underscore = function - | c -> Char.equal c '_' -;; - -(* S1mple parsers *) - -let parse_white_space = take_while is_whitespace -let parse_white_space1 = take_while1 is_whitespace -let parse_token s = parse_white_space *> s -let parse_token1 s = parse_white_space1 *> s -let parse_trim s = parse_white_space *> s <* parse_white_space -let pstrtoken s = parse_white_space *> string s -let pstrtoken1 s = parse_white_space1 *> string s -let parens p = pstrtoken "(" *> p <* pstrtoken ")" -let verticalbar p = pstrtoken "|" *> p -let parens_or_not p = p <|> parens p - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -(* Const parsers *) - -let parse_bool = - string "true" >>| (fun _ -> CBool true) <|> (string "false" >>| fun _ -> CBool false) -;; - -let parse_pos_int = take_while1 is_digit >>| fun b -> CInt (int_of_string b) -let parse_neg_int = char '-' *> take_while1 is_digit >>| fun b -> CInt (-int_of_string b) -let parse_int = parse_pos_int <|> parse_neg_int - -let parse_str = - char '"' *> take_while (fun a -> a != '"') <* char '"' >>| fun a -> CString a -;; - -let parse_const = parse_white_space *> choice [ parse_int; parse_bool; parse_str ] - -(* Parse var *) - -let check_var varname = - if is_keyword varname - then fail ("You can not use" ^ varname ^ "keywords as vars") - else if Char.is_digit @@ String.get varname 0 - then fail "Identifier first sumbol is letter, not digit" - else return varname -;; - -let var cond = - parse_white_space *> take_while1 cond - >>= fun v -> if String.length v == 0 then fail "Not identifier" else check_var v -;; - -let p_var = - let is_entry = function - | c -> is_lchar c || is_underscore c || is_digit c - in - var is_entry -;; - -(* Pattern parsers*) - -let parse_wild = (fun _ -> Wild) <$> pstrtoken "_" -let parse_Const = (fun v -> Const v) <$> parse_const -let parse_var = (fun v -> Var v) <$> p_var - -let parse_tuple parser = - lift2 - (fun a b -> Tuple (a :: b)) - (parser <* pstrtoken ",") - (sep_by1 (pstrtoken ",") parser) -;; - -let parse_list ps = - (fun v -> List v) <$> (pstrtoken "[" *> sep_by1 (pstrtoken ";") ps <* pstrtoken "]") -;; - -type pdispatch = - { value : pdispatch -> pattern t - ; tuple : pdispatch -> pattern t - ; list : pdispatch -> pattern t - ; pattern : pdispatch -> pattern t - } - -let pack = - let pattern pack = choice [ pack.tuple pack; pack.list pack; pack.value pack ] in - let parse pack = - choice [ pack.value pack; pack.list pack; parens @@ pack.tuple pack ] - in - let value pack = - fix - @@ fun _ -> - parse_white_space - *> (parse_wild <|> parse_Const <|> parse_var <|> parens @@ pack.value pack) - in - let tuple pack = - fix @@ fun _ -> parse_tuple (parse pack <|> parens @@ pack.tuple pack) - in - let list pack = fix @@ fun _ -> parse_list (parse pack <|> parens @@ pack.list pack) in - { value; tuple; list; pattern } -;; - -let pat = pack.pattern pack -let pargs = choice [ pack.list pack; pack.value pack ] - -(* Parse expr *) - -let pop ch op = pstrtoken ch *> return (fun e1 e2 -> BinExpr (op, e1, e2)) -let pmulti = pop "*" Mul <|> pop "/" Div <|> pop "%" Mod -let padd = pop "+" Add <|> pop "-" Sub -let pcomp = pop ">=" GEq <|> pop ">" Gre <|> pop "<=" LEq <|> pop "<" Less -let peq = pop "=" Eq <|> pop "<>" NEq -let pconj = pop "&&" And -let pdisj = pop "||" Or -let constr_econst e = ConstExpr e -let constr_ebinop op e1 e2 = BinExpr (op, e1, e2) -let constr_evar id = VarExpr id -let constr_elist l = ListExpr l -let constr_etuple t = TupleExpr t -let constr_eif e1 e2 e3 = IfExpr (e1, e2, e3) -let constr_efun pl e = List.fold_right ~init:e ~f:(fun p e -> FunExpr (p, e)) pl -let constr_elet r f = LetExpr (r, f) -let constr_ereclet r f = LetRecExpr (r, f) -let constr_eapp f args = List.fold_left ~init:f ~f:(fun f arg -> AppExpr (f, arg)) args -let parse_econst = (fun v -> ConstExpr v) <$> parse_const -let parse_evar = (fun v -> VarExpr v) <$> p_var -let pfun_args = fix @@ fun p -> many (pack.list pack <|> pack.value pack) <|> parens p -let pfun_args1 = fix @@ fun p -> many1 (pack.list pack <|> pack.value pack) <|> parens p - -let parse_list_expr ps = - (fun v -> ListExpr v) <$> (pstrtoken "[" *> sep_by1 (pstrtoken ";") ps <* pstrtoken "]") -;; - -let parse_tuple_expr ps = - (fun v -> TupleExpr v) - <$> (pstrtoken "(" *> sep_by1 (pstrtoken ",") ps - <* pstrtoken ")" - <|> sep_by1 (pstrtoken ",") ps) -;; - -let plet_body pargs pexpr = - parse_token1 pargs - >>= fun args -> pstrtoken "=" *> pexpr >>| fun expr -> constr_efun args expr -;; - -type edispatch = - { value_e : edispatch -> expr t - ; const_e : edispatch -> expr t - ; var_e : edispatch -> expr t - ; list_e : edispatch -> expr t - ; tuple_e : edispatch -> expr t - ; op_e : edispatch -> expr t - ; fun_e : edispatch -> expr t - ; let_e : edispatch -> expr t - ; app_e : edispatch -> expr t - ; if_e : edispatch -> expr t - ; expr : edispatch -> expr t - } - -let parens_only ps = parens @@ choice ps - -let pack = - let expr_parsers pack = - choice - [ pack.op_e pack - ; pack.tuple_e pack - ; pack.list_e pack - ; pack.app_e pack - ; pack.fun_e pack - ; pack.let_e pack - ; pack.if_e pack - ] - in - let expr pack = expr_parsers pack in - let const_e pack = fix @@ fun _ -> parse_econst <|> parens @@ pack.const_e pack in - let var_e pack = fix @@ fun _ -> parse_evar <|> parens @@ pack.var_e pack in - let value_e pack = fix @@ fun _ -> pack.const_e pack <|> pack.var_e pack in - let op_parsers pack = - choice - [ pack.list_e pack - ; pack.app_e pack - ; parens_only [ pack.tuple_e pack; pack.op_e pack ] - ; pack.var_e pack - ; pack.const_e pack - ] - in - let parse_if_state pack = - pack.op_e pack <|> pack.let_e pack <|> pack.app_e pack <|> pack.if_e pack - in - let list_parsers pack = pack.value_e pack <|> pack.list_e pack <|> pack.tuple_e pack in - let tuple_parsers pack = - pack.value_e pack <|> pack.list_e pack <|> parens @@ pack.tuple_e pack - in - let app_args_parsers pack = - choice - [ pack.list_e pack - ; parens_only - [ pack.op_e pack; pack.tuple_e pack; pack.fun_e pack; pack.app_e pack ] - ; pack.var_e pack - ; pack.const_e pack - ] - in - let op_e pack = - fix - @@ fun _ -> - let multi = chainl1 (op_parsers pack) pmulti in - let add = chainl1 multi padd in - let comp = chainl1 add pcomp in - let eq = chainl1 comp peq in - let conj = chainl1 eq pconj in - chainl1 conj pdisj <|> parens (pack.op_e pack) - in - let if_e pack = - fix - @@ fun _ -> - lift3 - constr_eif - (pstrtoken "if" *> parse_if_state pack) - (pstrtoken1 "then" *> expr pack) - (pstrtoken1 "else" *> expr pack) - <|> parens @@ pack.if_e pack - in - let list_e pack = - fix @@ fun _ -> parse_list_expr (list_parsers pack <|> parens @@ pack.list_e pack) - in - let tuple_e pack = - fix @@ fun _ -> parse_tuple_expr (tuple_parsers pack <|> parens @@ pack.tuple_e pack) - in - let let_e_without_rec pack = - fix - @@ fun _ -> - lift2 constr_elet (pstrtoken "let" *> p_var) (plet_body pfun_args (expr pack)) - in - let let_e_with_rec pack = - fix - @@ fun _ -> - lift2 constr_ereclet (pstrtoken "let rec" *> p_var) (plet_body pfun_args (expr pack)) - in - let fun_e pack = - fix - @@ fun _ -> - lift2 constr_efun (pstrtoken "fun" *> pfun_args1) (pstrtoken "->" *> expr pack) - <|> parens @@ pack.fun_e pack - in - let app_e pack = - fix - @@ fun _ -> - lift2 - constr_eapp - (pack.var_e pack <|> parens_only [ pack.fun_e pack; pack.app_e pack ]) - (many1 (parse_token1 @@ app_args_parsers pack)) - <|> parens @@ pack.app_e pack - in - let let_e pack = - fix - @@ fun _ -> - let_e_without_rec pack <|> let_e_with_rec pack <|> parens @@ pack.let_e pack - in - { var_e; const_e; op_e; list_e; tuple_e; fun_e; let_e; app_e; value_e; if_e; expr } -;; - -let parse = pack.expr pack - -(* TESTS *) -let start_test parser show input = - let res = start_parsing parser input in - match res with - | Ok res -> Format.printf "%s" (show res) - | Error err -> Format.printf "%s" err -;; - -(* Test const parser *) - -let%expect_test _ = - let test = "true" in - start_test parse_const show_const test; - [%expect {| (CBool true) |}] -;; - -let%expect_test _ = - let test = "\"itsastring\"" in - start_test parse_const show_const test; - [%expect {| (CString "itsastring") |}] -;; - -let%expect_test _ = - let test = "\"a\"" in - start_test parse_const show_const test; - [%expect {| (CString "a") |}] -;; - -let%expect_test _ = - let test = "\"123?/=_asdf\"" in - start_test parse_const show_const test; - [%expect {| (CString "123?/=_asdf") |}] -;; - -let%expect_test _ = - let test = "951753" in - start_test parse_const show_const test; - [%expect {| (CInt 951753) |}] -;; - -let%expect_test _ = - let test = "-951753" in - start_test parse_const show_const test; - [%expect {| (CInt -951753) |}] -;; - -(* Test pattern parser *) - -let%expect_test _ = - let test = "\"notvarname\"" in - start_test parse_Const show_pattern test; - [%expect {| (Const (CString "notvarname")) |}] -;; - -let%expect_test _ = - let test = "1234" in - start_test parse_Const show_pattern test; - [%expect {| (Const (CInt 1234)) |}] -;; - -let%expect_test _ = - let test = "-1234" in - start_test parse_Const show_pattern test; - [%expect {| (Const (CInt -1234)) |}] -;; - -let%expect_test _ = - let test = "varname" in - start_test parse_var show_pattern test; - [%expect {| (Var "varname") |}] -;; - -let%expect_test _ = - let test = "varname1" in - start_test parse_var show_pattern test; - [%expect {| (Var "varname1") |}] -;; - -let%expect_test _ = - let test = "varn1ame" in - start_test parse_var show_pattern test; - [%expect {| (Var "varn1ame") |}] -;; - -let%expect_test _ = - let test = "1varname" in - start_test parse_var show_pattern test; - [%expect {| : Identifier first sumbol is letter, not digit |}] -;; - -let%expect_test _ = - let test = "1,(2),3" in - start_test pat show_pattern test; - [%expect {| (Tuple [(Const (CInt 1)); (Const (CInt 2)); (Const (CInt 3))]) |}] -;; - -let%expect_test _ = - let test = "[((1));2;3]" in - start_test pat show_pattern test; - [%expect {| (List [(Const (CInt 1)); (Const (CInt 2)); (Const (CInt 3))]) |}] -;; - -let%expect_test _ = - let test = "a,\"b\",c" in - start_test pat show_pattern test; - [%expect {| (Tuple [(Var "a"); (Const (CString "b")); (Var "c")]) |}] -;; - -let%expect_test _ = - let test = "[(\"1\",2,3); (2,3,4,5)]" in - start_test pat show_pattern test; - [%expect - {| - (List - [(Tuple [(Const (CString "1")); (Const (CInt 2)); (Const (CInt 3))]); - (Tuple - [(Const (CInt 2)); (Const (CInt 3)); (Const (CInt 4)); - (Const (CInt 5))]) - ]) |}] -;; - -let%expect_test _ = - let test = "(((5)))" in - start_test pat show_pattern test; - [%expect {| (Const (CInt 5)) |}] -;; - -let%expect_test _ = - let test = "[1;2;3], 3" in - start_test pat show_pattern test; - [%expect - {| - (Tuple - [(List [(Const (CInt 1)); (Const (CInt 2)); (Const (CInt 3))]); - (Const (CInt 3))]) |}] -;; - -let%expect_test _ = - let test = "3, 1234, [1;2;3]" in - start_test pat show_pattern test; - [%expect - {| - (Tuple - [(Const (CInt 3)); (Const (CInt 1234)); - (List [(Const (CInt 1)); (Const (CInt 2)); (Const (CInt 3))])]) |}] -;; - -(* Test expr *) - -let%expect_test _ = - let test = "[1;2; 3]" in - start_test parse show_expr test; - [%expect - {| (ListExpr [(ConstExpr (CInt 1)); (ConstExpr (CInt 2)); (ConstExpr (CInt 3))]) |}] -;; - -let%expect_test _ = - let test = "1 * 3" in - start_test parse show_expr test; - [%expect {| (BinExpr (Mul, (ConstExpr (CInt 1)), (ConstExpr (CInt 3)))) |}] -;; - -let%expect_test _ = - let test = "1 + 3 * 4" in - start_test parse show_expr test; - [%expect - {| - (BinExpr (Add, (ConstExpr (CInt 1)), - (BinExpr (Mul, (ConstExpr (CInt 3)), (ConstExpr (CInt 4)))))) |}] -;; - -let%expect_test _ = - let test = "(3, 1234, [1;2;3])" in - start_test parse show_expr test; - [%expect - {| - (TupleExpr - [(ConstExpr (CInt 3)); (ConstExpr (CInt 1234)); - (ListExpr - [(ConstExpr (CInt 1)); (ConstExpr (CInt 2)); (ConstExpr (CInt 3))]) - ]) |}] -;; - -let%expect_test _ = - let test = "let f x = x+x" in - start_test parse show_expr test; - [%expect - {| - (LetExpr ("f", - (FunExpr ((Var "x"), (BinExpr (Add, (VarExpr "x"), (VarExpr "x"))))))) |}] -;; - -let%expect_test _ = - let test = "let rec f x = f * x" in - start_test parse show_expr test; - [%expect - {| - (LetRecExpr ("f", - (FunExpr ((Var "x"), (BinExpr (Mul, (VarExpr "f"), (VarExpr "x"))))))) |}] -;; - -let%expect_test _ = - let test = "if x=1 then x+1 else x-1" in - start_test parse show_expr test; - [%expect - {| - (IfExpr ((BinExpr (Eq, (VarExpr "x"), (ConstExpr (CInt 1)))), - (BinExpr (Add, (VarExpr "x"), (ConstExpr (CInt 1)))), - (BinExpr (Sub, (VarExpr "x"), (ConstExpr (CInt 1)))))) |}] -;; - -let%expect_test _ = - let test = "let rec fact n = if n = 1 then 1 else n * (fact (n - 1))" in - start_test parse show_expr test; - [%expect - {| - (LetRecExpr ("fact", - (FunExpr ((Var "n"), - (IfExpr ((BinExpr (Eq, (VarExpr "n"), (ConstExpr (CInt 1)))), - (ConstExpr (CInt 1)), - (BinExpr (Mul, (VarExpr "n"), - (AppExpr ((VarExpr "fact"), - (BinExpr (Sub, (VarExpr "n"), (ConstExpr (CInt 1)))))) - )) - )) - )) - )) |}] -;; diff --git a/FSharpActivePatterns/lib/parser.mli b/FSharpActivePatterns/lib/parser.mli deleted file mode 100644 index 887607ae3..000000000 --- a/FSharpActivePatterns/lib/parser.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Vitaliy Dyachkov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse : Ast.expr Angstrom.t diff --git a/FSharpUnitsOfMeasure/.gitignore b/FSharpUnitsOfMeasure/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/FSharpUnitsOfMeasure/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/FSharpUnitsOfMeasure/.ocamlformat b/FSharpUnitsOfMeasure/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/FSharpUnitsOfMeasure/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/FSharpUnitsOfMeasure/COPYING b/FSharpUnitsOfMeasure/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/FSharpUnitsOfMeasure/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/FSharpUnitsOfMeasure/COPYING.CC0 b/FSharpUnitsOfMeasure/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/FSharpUnitsOfMeasure/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/FSharpUnitsOfMeasure/COPYING.LESSER b/FSharpUnitsOfMeasure/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/FSharpUnitsOfMeasure/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/FSharpUnitsOfMeasure/DONT_REMOVE_THIS_DIRECTORY.md b/FSharpUnitsOfMeasure/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/FSharpUnitsOfMeasure/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/FSharpUnitsOfMeasure/FSharpUnitsOfMeasure.opam b/FSharpUnitsOfMeasure/FSharpUnitsOfMeasure.opam deleted file mode 100644 index e25bebbd1..000000000 --- a/FSharpUnitsOfMeasure/FSharpUnitsOfMeasure.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for Fsharp" -description: "Support for Units of Measure" -maintainer: ["Efim Perevalov"] -authors: ["Efim Perevalov"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/Urtix/fp2023" -bug-reports: "https://github.com/Urtix/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/FSharpUnitsOfMeasure/Makefile b/FSharpUnitsOfMeasure/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/FSharpUnitsOfMeasure/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/FSharpUnitsOfMeasure/README.md b/FSharpUnitsOfMeasure/README.md deleted file mode 100644 index 0d40699f9..000000000 --- a/FSharpUnitsOfMeasure/README.md +++ /dev/null @@ -1,93 +0,0 @@ -### An implementaion of F# and Units of Measure - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Efim Perevalov, es.perevalov@mail.ru - -Features done: - -- Parser - -Features in progress (and TODOs): - -- interpreter of non-recursive functions - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/FSharpUnitsOfMeasure/dune b/FSharpUnitsOfMeasure/dune deleted file mode 100644 index a0b026242..000000000 --- a/FSharpUnitsOfMeasure/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) \ No newline at end of file diff --git a/FSharpUnitsOfMeasure/dune-project b/FSharpUnitsOfMeasure/dune-project deleted file mode 100644 index 1e8528fe5..000000000 --- a/FSharpUnitsOfMeasure/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Efim Perevalov") - -(maintainers "Efim Perevalov") - -(bug_reports "https://github.com/Urtix/fp2023/issues") - -(homepage "https://github.com/Urtix/fp2023") - -(package - (name FSharpUnitsOfMeasure) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "An interpreter for Fsharp") - (description - "Support for Units of Measure") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/FSharpUnitsOfMeasure/lib/ast.ml b/FSharpUnitsOfMeasure/lib/ast.ml deleted file mode 100644 index 946023dc6..000000000 --- a/FSharpUnitsOfMeasure/lib/ast.ml +++ /dev/null @@ -1,42 +0,0 @@ -(** Copyright 2023-2024, Efim Perevalov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type id = string [@@deriving show { with_path = false }] - -type types = - | FInt of int (** integer number: 0,1,2,...*) - | FString of string (** string values: "Ocaml" *) - | FBool of bool (** boolean values: true and false *) - | FNil (** empty list: [] *) - | FUnit (** ()*) - | FFloat of float (** float number: ..., 0.1, ..., 1.2, ...*) -[@@deriving show { with_path = false }] - -type binary_op = - | Add (** + *) - | Sub (** - *) - | Mul (** * *) - | Div (** / *) - | Mod (** % *) - | And (** && *) - | Or (** || *) - | Eq (** = *) - | Less (* < *) - | Gre (** > *) - | Leq (** <= *) - | Greq (** >= *) -[@@deriving show { with_path = false }] - -type expression = - | ETypes of types - | EVar of id - | EBinaryOp of binary_op - | EList of expression * expression - | ETuple of expression list - | EApp of expression * expression - | EIfElse of expression * expression * expression - | ELet of id * expression - | ELetRec of id * expression - | EFun of expression * expression -[@@deriving show { with_path = false }] \ No newline at end of file diff --git a/FSharpUnitsOfMeasure/lib/dune b/FSharpUnitsOfMeasure/lib/dune deleted file mode 100644 index 299e51069..000000000 --- a/FSharpUnitsOfMeasure/lib/dune +++ /dev/null @@ -1,11 +0,0 @@ -(library - (name FSharpUnitsOfMeasure_lib) - (public_name FSharpUnitsOfMeasure.Lib) - (modules Ast Parser) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) - diff --git a/FSharpUnitsOfMeasure/lib/parser.ml b/FSharpUnitsOfMeasure/lib/parser.ml deleted file mode 100644 index f8d3632bb..000000000 --- a/FSharpUnitsOfMeasure/lib/parser.ml +++ /dev/null @@ -1,354 +0,0 @@ -(** Copyright 2021-2023, Efim Perevalov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Angstrom - -let empty_space = function - - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let lower_letter = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let upper_letter = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let ident_symbol = function - | c -> lower_letter c || upper_letter c || digit c || Char.equal c '_' -;; - -let keywords = function - | "let" - | "rec" - | "fun" - | "in" - | "if" - | "then" - | "else" - | "true" - | "false" - | "match" - | "with" - | "function" -> true - | _ -> false -;; - -let take_empty = take_while empty_space -let take_empty1 = take_while1 empty_space -let token s = take_empty *> s -let token1 s = take_empty1 *> s -let stoken s = take_empty *> string s -let stoken1 s = take_empty1 *> string s -let brackets p = stoken "(" *> p <* stoken ")" -let quotes p = stoken "\"" *> p <* stoken "\"" -let parens_or_not p = p <|> brackets p -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc - in e >>= fun init -> go init -;; - -(** Types constructor *) - -let fint x = FInt x -let fbool x = FBool x -let fstring x = FString x -let fnil = FNil -let funit = FUnit - -(** Types parse *) - -let parse_sign = - choice [ stoken "+" *> return 1; stoken "-" *> return (-1); stoken "" *> return 1 ] -;; - -let parse_fint = - let parse_digit = take_while1 digit - in lift2 (fun s v -> fint (s * Int.of_string v)) parse_sign parse_digit -;; - -let parse_fbool = - lift (fun b -> fbool @@ Bool.of_string b) - (stoken "false" <|> stoken "true") -;; - -let parse_fstring = - lift - (fun s -> fstring s) - (quotes @@ take_while (fun c -> not (Char.equal c '"'))) -;; - -let parse_fnil = stoken "[]" *> return fnil -let parse_funit = stoken "()" *> return funit -let parse_types = parse_fint <|> parse_fbool <|> parse_fstring <|> parse_fnil <|> parse_funit - -(** Ident parse *) - -let parse_id = - take_empty *> take_while1 ident_symbol - >>= fun res -> - if String.length res == 0 - then fail "Not identifier" - else if keywords res - then fail "You can not use keywords as vars" - else if Char.is_digit @@ String.get res 0 - then fail "Identifier first sumbol is letter, not digit" - else return res -;; - -(** Expression constructors *) - -let eifelse i t e = EIfElse (i, t, e) -let elet name body = ELet (name, body) -let eletrec name body = ELetRec (name, body) -let efun id body = EFun (id, body) -let eapp f a = EApp (f, a) -let evar x = EVar x - -(** Expression parse *) - -let parse_evar = evar <$> parse_id -let parse_etypes = parse_types >>| fun x -> ETypes x -let parse_arg = many @@ parens_or_not parse_evar -let parse_arg1 = many1 @@ parens_or_not parse_evar - -type edispatch = - { - evar : edispatch -> expression t; - etypes : edispatch -> expression t; - eifelse : edispatch -> expression t; - elet: edispatch -> expression t; - eletrec: edispatch -> expression t; - ebinaryop: edispatch -> expression t; - eapp: edispatch -> expression t; - expression: edispatch -> expression t - } - -let eifelse i expr = - take_empty *> lift3 eifelse - (stoken "if" *> i) - (stoken "then" *> expr) - (stoken "else" *> expr) -;; - -let construct_efun arg body = - let rec helper = function - | [] -> body - | hd :: tl -> efun hd (helper tl) - in helper arg -;; - -let parse_rec = - stoken "let" *> option "false" (stoken1 "rec") >>| fun x -> x != "false" -;; - -let eletfun parse_expr = - take_empty - *> lift4 - (fun r name arg body -> - let body = construct_efun arg body - in if r then eletrec name body else elet name body) - parse_rec - parse_id - parse_arg - (stoken "=" *> parse_expr) -;; - -(** Binary operations constructors *) - -let ebinop op e1 e2 = eapp op (eapp e1 e2) -let ediv = ebinop @@ EBinaryOp Div -let emul = ebinop @@ EBinaryOp Mul -let eadd = ebinop @@ EBinaryOp Add -let esub = ebinop @@ EBinaryOp Sub -let eless = ebinop @@ EBinaryOp Less -let eleq = ebinop @@ EBinaryOp Leq -let egre = ebinop @@ EBinaryOp Gre -let egreq = ebinop @@ EBinaryOp Greq -let emod = ebinop @@ EBinaryOp Mod -let eand = ebinop @@ EBinaryOp And -let eor = ebinop @@ EBinaryOp Or -let eeq = ebinop @@ EBinaryOp Eq - -let parse_binaryop expr = - let lvl1 = take_empty *> choice - [ - string "*" *> return emul; - string "/" *> return ediv; - string "%" *> return emod - ] - in let lvl2 = - take_empty *> choice - [ - string "+" *> return eadd; - string "-" *> return esub - ] - in let lvl3 = - take_empty *> choice - [ - string ">=" *> return egreq; - string ">" *> return egre; - string "<=" *> return eleq; - string "<" *> return eless - ] - in let lvl4 = take_empty *> string "=" *> return eeq; - in let lvl5 = take_empty *> string "&&" *> return eand - in let lvl6 = take_empty *> string "||" *> return eor - in let expr = chainl1 expr lvl1 - in let expr = chainl1 expr lvl2 - in let expr = chainl1 expr lvl3 - in let expr = chainl1 expr lvl4 - in let expr = chainl1 expr lvl5 - in chainl1 expr lvl6 -;; - -let parse_eapp parse_expr = - take_empty *> lift2 - (fun expr l -> let res = List.fold_left ~f:eapp ~init:expr l - in res) - parse_expr (many (token1 parse_expr)) -;; - -let pack = - let etypes _ = parse_etypes - in let evar _ = parse_evar - in let lets pack = choice [ pack.elet pack; pack.eletrec pack ] <* take_empty - in let expression pack = choice - [ - lets pack; - pack.eifelse pack; - pack.eapp pack; - ] - in - let eifelse pack = - fix @@ fun _ -> - let parse_eifelse = - parens_or_not @@ choice - [ - pack.eifelse pack; - pack.eapp pack; - ] - in eifelse parse_eifelse (pack.expression pack) - in - let ebinaryop pack = - fix @@ fun _ -> - let parse_ebinaryop = choice - [ - brackets @@ pack.eifelse pack; - brackets @@ pack.ebinaryop pack; - brackets @@ pack.eapp pack; - pack.etypes pack; - pack.evar pack - ] - in parens_or_not @@ parse_binaryop parse_ebinaryop - in let eapp pack = - fix @@ fun _ -> - let parse_eapp_pack = choice - [ - pack.ebinaryop pack; - brackets @@ pack.eifelse pack; - brackets @@ pack.eapp pack - ] - in parse_eapp parse_eapp_pack - in - let parse_lets pack = choice - [ - pack.eapp pack; - pack.eifelse pack - ] - in let elet pack = fix @@ fun _ -> eletfun @@ parse_lets pack - in let eletrec pack = fix @@ fun _ -> eletfun @@ parse_lets pack - in - { - evar; - etypes; - eifelse; - elet; - eletrec; - ebinaryop; - eapp; - expression - } -;; - -let parse_expression = pack.expression pack -let parse_program = many1 (token parse_expression <* token (many1 (stoken ";;"))) -let parse_str p s = parse_string ~consume:All p s -let parse str = parse_str parse_program (String.strip str) - - -(** Tests *) - -let parsed_result str parser show = - match parse_str parser str with - | Ok res -> Format.printf "%s" (show res) - | Error e -> Format.printf "%s" e -;; - -(** Types test*) - -let%expect_test _ = - parsed_result "777" parse_types show_types; - [%expect {| (FInt 777) |}] -;; - -let%expect_test _ = - parsed_result "-777" parse_types show_types; - [%expect {| (FInt -777) |}] -;; - -let%expect_test _ = - parsed_result "true" parse_types show_types; - [%expect {| (FBool true) |}] -;; - -let%expect_test _ = - parsed_result "false" parse_types show_types; - [%expect {| (FBool false) |}] -;; - -let%expect_test _ = - parsed_result "\"May the power be with us\"" parse_types show_types; - [%expect {| (FString "May the power be with us") |}] -;; - -let%expect_test _ = - parsed_result "let rec fact n = if n = 1 then 1 else n * (fact (n - 1))" parse_expression show_expression; - [%expect - {| - (ELetRec ("fact", - (EFun ((EVar "n"), - (EIfElse ( - (EApp ((EBinaryOp Eq), (EApp ((EVar "n"), (ETypes (FInt 1)))))), - (ETypes (FInt 1)), - (EApp ((EBinaryOp Mul), - (EApp ((EVar "n"), - (EApp ((EVar "fact"), - (EApp ((EBinaryOp Sub), - (EApp ((EVar "n"), (ETypes (FInt 1)))))) - )) - )) - )) - )) - )) - )) |}] -;; -;; - -let%expect_test _ = - parsed_result "()" parse_types show_types; - [%expect {| FUnit |}] -;; diff --git a/Go/.gitignore b/Go/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Go/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Go/.ocamlformat b/Go/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Go/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Go/COPYING b/Go/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Go/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Go/COPYING.CC0 b/Go/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Go/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Go/COPYING.LESSER b/Go/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Go/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Go/Lambda.opam b/Go/Lambda.opam deleted file mode 100644 index 10e12e5e3..000000000 --- a/Go/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Nikita Lukonenko"] -authors: ["Nikita Lukonenko"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Go/Makefile b/Go/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Go/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Go/README.md b/Go/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/Go/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Go/REPL.ml b/Go/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Go/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Go/demos/demoAO.ml b/Go/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/Go/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Go/demos/demoNO.ml b/Go/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Go/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Go/demos/demoParse.ml b/Go/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Go/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Go/demos/demo_input.txt b/Go/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Go/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Go/demos/dune b/Go/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Go/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Go/demos/interpretTests.t b/Go/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/Go/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Go/demos/parsingTests.t b/Go/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/Go/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Go/dune b/Go/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Go/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Go/dune-project b/Go/dune-project deleted file mode 100644 index 158ccdcb3..000000000 --- a/Go/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Nikita Lukonenko") - -(maintainers "Nikita Lukonenko") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Go/lib/Pprintast.ml b/Go/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Go/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Go/lib/Pprintast.mli b/Go/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Go/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Go/lib/Printast.ml b/Go/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Go/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Go/lib/Printast.mli b/Go/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Go/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Go/lib/ast.mli b/Go/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Go/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Go/lib/dune b/Go/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Go/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Go/lib/interpret.ml b/Go/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Go/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Go/lib/interpret.mli b/Go/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Go/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Go/lib/lambda.ml b/Go/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Go/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Go/lib/lambda.mli b/Go/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Go/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Go/lib/parser.ml b/Go/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Go/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Go/lib/parser.mli b/Go/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Go/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Go/lib/tests.ml b/Go/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Go/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Go/lib/utils.ml b/Go/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Go/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Go/lib/utils.mli b/Go/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Go/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Go/repl.t b/Go/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Go/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/Haskell/.gitignore b/Haskell/.gitignore deleted file mode 100644 index 8e38f4fe9..000000000 --- a/Haskell/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs - diff --git a/Haskell/.ocamlformat b/Haskell/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Haskell/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Haskell/COPYING b/Haskell/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Haskell/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Haskell/COPYING.CC0 b/Haskell/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Haskell/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Haskell/COPYING.LESSER b/Haskell/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Haskell/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Haskell/DONT_REMOVE_THIS_DIRECTORY.md b/Haskell/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Haskell/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Haskell/Haskell.opam b/Haskell/Haskell.opam deleted file mode 100644 index 1a67ff775..000000000 --- a/Haskell/Haskell.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for Haskell" -description: - "haskell is being supported pogchamp times 3 fire emoji times 3." -maintainer: ["Danil Parfyonov"] -authors: ["Danil Parfyonov"] -license: "LGPL-3.0-or-later" -homepage: "github.com/ancavar/fp2023/issues" -bug-reports: "github.com/ancavar/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Haskell/Makefile b/Haskell/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Haskell/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Haskell/README.md b/Haskell/README.md deleted file mode 100644 index c97eaac0f..000000000 --- a/Haskell/README.md +++ /dev/null @@ -1,8 +0,0 @@ -### An implementaion of Haskell interpreter - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Danil Parfyonov, daniel.parfyonov@gmail.com - diff --git a/Haskell/demos/dune b/Haskell/demos/dune deleted file mode 100644 index f82d6509c..000000000 --- a/Haskell/demos/dune +++ /dev/null @@ -1,9 +0,0 @@ -(executable - (name haskellParser) - (public_name haskellParser) - (libraries haskellLib base) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps ./haskellParser.exe)) diff --git a/Haskell/demos/haskellParser.ml b/Haskell/demos/haskellParser.ml deleted file mode 100644 index c15419fe3..000000000 --- a/Haskell/demos/haskellParser.ml +++ /dev/null @@ -1,20 +0,0 @@ -(** Copyright 2023-2024, Danil P *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open HaskellLib - -let parse s = - match Parser.parse s with - | Ok a -> a - | Error err -> - Format.printf "%s\n" err; - Stdlib.exit 1 -;; - -let () = - In_channel.(input_all stdin) - |> parse - |> Ast.show_prog - |> Out_channel.(output_string stdout) -;; diff --git a/Haskell/demos/haskellParser.t b/Haskell/demos/haskellParser.t deleted file mode 100644 index 23f8a682d..000000000 --- a/Haskell/demos/haskellParser.t +++ /dev/null @@ -1,37 +0,0 @@ - $ ./haskellParser.exe < fact n = if (n < 2) then 1 else fact (n - 1) * n - > EOF - [(DeclLet - ((PatVar "fact"), - (ExprFunc - ((PatVar "n"), - (ExprIf ((ExprBinOp (Lt, (ExprVar "n"), (ExprLit (LitInt 2)))), - (ExprLit (LitInt 1)), - (ExprBinOp (Mul, - (ExprApp ((ExprVar "fact"), - (ExprBinOp (Sub, (ExprVar "n"), (ExprLit (LitInt 1)))))), - (ExprVar "n"))) - )))))) - ] - -yet another factorial - $ ./haskellParser.exe < fact 0 = 1 - > fact n = n * fact (n - 1) - > EOF - [(DeclLet - ((PatVar "fact"), (ExprFunc ((PatLit (LitInt 0)), (ExprLit (LitInt 1)))))); - (DeclLet - ((PatVar "fact"), - (ExprFunc - ((PatVar "n"), - (ExprBinOp (Mul, (ExprVar "n"), - (ExprApp ((ExprVar "fact"), - (ExprBinOp (Sub, (ExprVar "n"), (ExprLit (LitInt 1)))))) - )))))) - ] - - $ ./haskellParser.exe < x=1 - > EOF - [(DeclLet ((PatVar "x"), (ExprLit (LitInt 1))))] diff --git a/Haskell/dune b/Haskell/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/Haskell/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/Haskell/dune-project b/Haskell/dune-project deleted file mode 100644 index 30cea244d..000000000 --- a/Haskell/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Danil Parfyonov") - -(maintainers "Danil Parfyonov") - -(bug_reports "github.com/ancavar/fp2023/issues") - -(homepage "github.com/ancavar/fp2023/issues") - -(package - (name Haskell) - (synopsis "An interpreter for Haskell") - (description - "haskell is being supported pogchamp times 3 fire emoji times 3.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Haskell/lib/ast.ml b/Haskell/lib/ast.ml deleted file mode 100644 index 75c35e61f..000000000 --- a/Haskell/lib/ast.ml +++ /dev/null @@ -1,67 +0,0 @@ -(** Copyright 2023-2024, Danil P *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type id = string [@@deriving eq, show { with_path = false }] - -type un_op = - | Neg - | Not -[@@deriving eq, show { with_path = false }] - -type bin_op = - | Add (** + *) - | Sub (** - *) - | Mul (** * *) - | Div (** / *) - | And (** && *) - | Or (** || *) - | Eq (** /= *) - | Neq (** <> *) - | Lt (** < *) - | Gt (** > *) - | Leq (** <= *) - | Geq (** >= *) -[@@deriving eq, show { with_path = false }] - -type binding = pat * expr [@@deriving eq, show { with_path = false }] - -(** Alternatives in case expression *) -and alt = pat * expr [@@deriving eq, show { with_path = false }] - -and expr = - | ExprLit of lit - | ExprVar of id - | ExprFunc of binding (** Essentially a closure *) (* TODO: * local bindings???*) - | ExprApp of expr * expr - | ExprIf of expr * expr * expr - | ExprTuple of expr list - | ExprCons of expr * expr - | ExprNil - | ExprCase of expr * alt list - | ExprBinOp of bin_op * expr * expr - | ExprUnOp of un_op * expr - | ExprLet of binding list * expr (** Local binding [let x = 2; y = 3 in e x y] *) -[@@deriving eq, show { with_path = false }] - -and pat = - | PatWild (** Wildcard Pat [_] *) - | PatVar of id (** Variable Pat (name binding) [x] *) - | PatLit of lit (** Literal pat [1], ['a'], ["hello"] *) - | PatTuple of pat list (** Tuple pat [(x, y)] *) - | PatCon of pat * pat (** Constructor pat *) - | PatAs of id * pat (** As-pat [list@(x:xs)] *) - | PatList of pat list - | PatRec of id * pat list (**Record pat [Point {x = 3, y}] *) - | PatNil (** [] *) -[@@deriving eq, show { with_path = false }] - -and lit = - | LitInt of int - | LitChar of char - | LitString of string - | LitFloat of float -[@@deriving eq, show { with_path = false }] - -and decl = DeclLet of binding [@@deriving eq, show { with_path = false }] -and prog = decl list [@@deriving eq] diff --git a/Haskell/lib/dune b/Haskell/lib/dune deleted file mode 100644 index e07374212..000000000 --- a/Haskell/lib/dune +++ /dev/null @@ -1,19 +0,0 @@ -(library - (name haskellLib) - (public_name Haskell.lib) - (modules Parser Ast) - (libraries base angstrom ppx_show.runtime) - (instrumentation - (backend bisect_ppx)) - (preprocess - (pps ppx_deriving.eq ppx_deriving.show))) - -(library - (name tests) - (modules tests) - (libraries haskellLib) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Haskell/lib/parser.ml b/Haskell/lib/parser.ml deleted file mode 100644 index 0357694ef..000000000 --- a/Haskell/lib/parser.ml +++ /dev/null @@ -1,198 +0,0 @@ -(** Copyright 2023-2024, Danil P *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Ast - -let is_ws = function - | ' ' | '\t' -> true - | _ -> false -;; - -let is_eol = function - | '\n' | '\r' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_alpha = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_capital = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_keyword = function - | "case" - | "of" - | "if" - | "then" - | "else" - | "let" - | "in" - | "where" - | "data" - | "True" - | "False" -> true - | _ -> false -;; - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let pwspaces = take_while is_ws -let pwspaces1 = take_while1 is_ws -let pspaces = take_while (fun c -> is_ws c || is_eol c) -let pspaces1 = take_while1 (fun c -> is_ws c || is_eol c) -let ptoken p = pwspaces *> p -let ptoken1 p = pwspaces1 *> p -let pstoken s = ptoken (string s) -let pstoken1 s = ptoken1 (string s) -let between l r p = pstoken l *> p <* pstoken r -let pparens p = between "(" ")" p -let pbrackets p = between "[" "]" p -let lit_int s = LitInt (int_of_string s) -let lit_str s = LitString s -let lit_char s = LitChar s -let expr_var id = ExprVar id -let expr_lit lit = ExprLit lit -let expr_fun args expr = List.fold_right (fun p e -> ExprFunc (p, e)) args expr -let expr_binop op lexp rexp = ExprBinOp (op, lexp, rexp) -let expr_tuple l = ExprTuple l -let expr_app o1 o2 = ExprApp (o1, o2) -let pat_var pat = PatVar pat -let pat_lit lit = PatLit lit -let pat_wild _ = PatWild -let pat_list l = PatList l -let pat_tuple l = PatTuple l -let dec_let pat expr = DeclLet (pat, expr) - -let pname = - ptoken - @@ lift2 - (fun hd tl -> String.make 1 hd ^ tl) - (satisfy (fun ch -> ch = '_' || is_alpha ch)) - (take_while (fun ch -> - ch = '_' || ch = '\'' || is_alpha ch || is_capital ch || is_digit ch)) - >>= fun s -> - if is_keyword s - then fail "Parsing error: keyword reserved" - else if s = "_" - then fail "Parsing error: wildcard `_` isn't supported" - else return s -;; - -(* Literals *) - -let pint = lit_int <$> ptoken @@ take_while1 is_digit -let pstring = lit_str <$> ptoken @@ (char '"' *> take_till (Char.equal '"')) <* char '"' -let pchar = lit_char <$> ptoken @@ (char '\'' *> any_char) <* char '\'' -let plit = choice [ pint; pstring; pchar ] - -(* Patterns *) - -let ppat = - fix - @@ fun pattern -> - let pplit = pat_lit <$> plit in - let pwild = pat_wild <$> pstoken "_" in - let ppvar = pat_var <$> pname in - let pplist = - let contents = sep_by (char ',') @@ ptoken pattern in - pbrackets contents >>| pat_list - in - let pptuple = - let contents = sep_by (char ',') @@ ptoken pattern in - pparens contents - >>= function - | [ x ] -> return x - | elems -> return (pat_tuple elems) - in - choice [ pplist; pptuple; pplit; ppvar; pwild ] -;; - -(* Expressions *) - -let pbinop op op_constr = pstoken op *> return (expr_binop op_constr) -let padd = pbinop "+" Add -let psub = pbinop "-" Sub -let pmul = pbinop "*" Mul -let pdiv = pbinop "/" Div -let pand = pbinop "&&" And -let por = pbinop "||" Or -let peq = pbinop "==" Eq -let pneq = pbinop "/=" Neq -let plt = pbinop "<" Lt -let pgt = pbinop ">" Gt -let pleq = pbinop "<=" Leq -let pgeq = pbinop ">=" Geq - -let pexpr = - fix - @@ fun pexpr -> - let pexprvar = expr_var <$> pname in - let pexprlit = expr_lit <$> plit in - let pvalue = choice [ pexprlit; pexprvar; (* pneg; *) pparens pexpr ] in - let pebinop = - let app = chainl1 pvalue (return expr_app) in - let pmuldiv = - let op = choice [ pmul; pdiv ] in - chainl1 app op - in - let paddsub = - let op = choice [ padd; psub ] in - chainl1 pmuldiv op - in - let pcmpr = - let op = choice [ peq; pneq; pleq; pgeq; plt; pgt ] in - chainl1 paddsub op - in - let pandor = - let op = choice [ pand; por ] in - chainl1 pcmpr op - in - pandor - in - let pif = - pstoken "if" *> pexpr - <* pstoken1 "then" - <* pwspaces1 - >>= fun cond -> - pexpr - <* pstoken1 "else" - <* pwspaces1 - >>= fun then_branch -> - pexpr >>| fun else_branch -> ExprIf (cond, then_branch, else_branch) - in - (* let pcase = - pstoken "case" *> ptoken pexpr - <* pstoken1 "of" - <* pspaces1 - >>= fun caseexpr -> - many1 - (ppat - <* string "->" - <* space - >>= fun pat -> parse_expr <* space >>| fun result_expr -> pat, result_expr) - >>| fun branches -> Case (case_expr, branches) - in *) - choice [ pif; pebinop ] -;; - -let pdecl = - lift2 dec_let (ptoken ppat) (lift2 expr_fun (many ppat) (pstoken "=" *> ptoken pexpr)) - <* pspaces -;; - -let pprog : prog t = many1 (ptoken pdecl <* ptoken @@ many @@ pstoken ";;") -let parse s = parse_string ~consume:All pprog s diff --git a/Haskell/lib/tests.ml b/Haskell/lib/tests.ml deleted file mode 100644 index 9c8024304..000000000 --- a/Haskell/lib/tests.ml +++ /dev/null @@ -1,34 +0,0 @@ -(** Copyright 2023-2024, Danil P *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open HaskellLib -open Ast - -let ptest s e = - match Parser.parse s with - | Ok a -> List.equal equal_decl e a - | Error err -> - Format.printf "%s\n" err; - false -;; - -let%test _ = ptest "x = 2" [ DeclLet (PatVar "x", ExprLit (LitInt 2)) ] - -let%test _ = - ptest - "fact n = if (n < 2) then 1 else fact (n - 1) * n" - [ DeclLet - ( PatVar "fact" - , ExprFunc - ( PatVar "n" - , ExprIf - ( ExprBinOp (Lt, ExprVar "n", ExprLit (LitInt 2)) - , ExprLit (LitInt 1) - , ExprBinOp - ( Mul - , ExprApp - (ExprVar "fact", ExprBinOp (Sub, ExprVar "n", ExprLit (LitInt 1))) - , ExprVar "n" ) ) ) ) - ] -;; diff --git a/Javascript/.gitignore b/Javascript/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Javascript/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Javascript/.ocamlformat b/Javascript/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Javascript/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Javascript/COPYING b/Javascript/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Javascript/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Javascript/COPYING.CC0 b/Javascript/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Javascript/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Javascript/COPYING.LESSER b/Javascript/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Javascript/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Javascript/DONT_REMOVE_THIS_DIRECTORY.md b/Javascript/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Javascript/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Javascript/Lambda.opam b/Javascript/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/Javascript/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Javascript/Makefile b/Javascript/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Javascript/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Javascript/README.md b/Javascript/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/Javascript/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Javascript/REPL.ml b/Javascript/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Javascript/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Javascript/demos/demoAO.ml b/Javascript/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/Javascript/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Javascript/demos/demoNO.ml b/Javascript/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Javascript/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Javascript/demos/demoParse.ml b/Javascript/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Javascript/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Javascript/demos/demo_input.txt b/Javascript/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Javascript/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Javascript/demos/dune b/Javascript/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Javascript/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Javascript/demos/interpretTests.t b/Javascript/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/Javascript/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Javascript/demos/parsingTests.t b/Javascript/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/Javascript/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Javascript/dune b/Javascript/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Javascript/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Javascript/dune-project b/Javascript/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/Javascript/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Javascript/lib/Pprintast.ml b/Javascript/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Javascript/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Javascript/lib/Pprintast.mli b/Javascript/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Javascript/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Javascript/lib/Printast.ml b/Javascript/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Javascript/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Javascript/lib/Printast.mli b/Javascript/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Javascript/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Javascript/lib/ast.mli b/Javascript/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Javascript/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Javascript/lib/dune b/Javascript/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Javascript/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Javascript/lib/interpret.ml b/Javascript/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Javascript/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Javascript/lib/interpret.mli b/Javascript/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Javascript/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Javascript/lib/lambda.ml b/Javascript/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Javascript/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Javascript/lib/lambda.mli b/Javascript/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Javascript/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Javascript/lib/parser.ml b/Javascript/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Javascript/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Javascript/lib/parser.mli b/Javascript/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Javascript/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Javascript/lib/tests.ml b/Javascript/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Javascript/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Javascript/lib/utils.ml b/Javascript/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Javascript/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Javascript/lib/utils.mli b/Javascript/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Javascript/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Javascript/repl.t b/Javascript/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Javascript/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/LLVM_IR/.gitignore b/LLVM_IR/.gitignore deleted file mode 100644 index 742dc6933..000000000 --- a/LLVM_IR/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs -.notes \ No newline at end of file diff --git a/LLVM_IR/.ocamlformat b/LLVM_IR/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/LLVM_IR/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/LLVM_IR/COPYING b/LLVM_IR/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/LLVM_IR/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/LLVM_IR/COPYING.CC0 b/LLVM_IR/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/LLVM_IR/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/LLVM_IR/COPYING.LESSER b/LLVM_IR/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/LLVM_IR/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/LLVM_IR/LLVM_IR.opam b/LLVM_IR/LLVM_IR.opam deleted file mode 100644 index d440bdcec..000000000 --- a/LLVM_IR/LLVM_IR.opam +++ /dev/null @@ -1,38 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for LLVM Intermediate Representation" -description: - "An interpreter for LLVM Intermediate Representation with interesting features, also known as bugs" -maintainer: ["Efremov Alexey"] -authors: ["Efremov Alexey"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/Kakadu/fp2023/tree/master/LLVM_IR" -bug-reports: "https://github.com/Kakadu/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -depexts: [ - [ "llvm-15-dev" "clang-15" ] {os-distribution = "ubuntu"} -] \ No newline at end of file diff --git a/LLVM_IR/LLVM_IR.opam.template b/LLVM_IR/LLVM_IR.opam.template deleted file mode 100644 index 390cb195b..000000000 --- a/LLVM_IR/LLVM_IR.opam.template +++ /dev/null @@ -1,3 +0,0 @@ -depexts: [ - [ "llvm-15-dev" "clang-15" ] {os-distribution = "ubuntu"} -] \ No newline at end of file diff --git a/LLVM_IR/Makefile b/LLVM_IR/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/LLVM_IR/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/LLVM_IR/README.md b/LLVM_IR/README.md deleted file mode 100644 index 940d78834..000000000 --- a/LLVM_IR/README.md +++ /dev/null @@ -1,15 +0,0 @@ -### An implementaion of LLVM IR interpretator - -This is a homework for functional programming course. - -License: LGPL-3.0 - -Author: Efremov Alexey - -Features done (append only): - -- Parser of factorial - -Features in progress (and TODOs): - -- Parser (need add global vars and maybe attributes) diff --git a/LLVM_IR/demos/attachments/fac.ll b/LLVM_IR/demos/attachments/fac.ll deleted file mode 100644 index aa39deb79..000000000 --- a/LLVM_IR/demos/attachments/fac.ll +++ /dev/null @@ -1,36 +0,0 @@ -; Copyright 2023-2024, Efremov Alexey -; SPDX-License-Identifier: CC0-1.0 - -define i32 @fac(i32 %0) { - %2 = alloca i32, align 4 - %3 = alloca i32, align 4 - store i32 %0, ptr %3, align 4 - %4 = load i32, ptr %3, align 4 - %5 = icmp slt i32 %4, 1 - br i1 %5, label %6, label %7 - -6: ; preds = %1 - store i32 1, ptr %2, align 4 - br label %13 - -7: ; preds = %1 - %8 = load i32, ptr %3, align 4 - %9 = sub nsw i32 %8, 1 - %10 = call i32 @fac(i32 %9) - %11 = load i32, ptr %3, align 4 - %12 = mul nsw i32 %10, %11 - store i32 %12, ptr %2, align 4 - br label %13 - -13: ; preds = %7, %6 - %14 = load i32, ptr %2, align 4 - ret i32 %14 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @main() { - %1 = alloca i32, align 4 - store i32 0, ptr %1, align 4 - %2 = call i32 @fac(i32 5) - ret i32 %2 -} \ No newline at end of file diff --git a/LLVM_IR/demos/attachments/fac_arg.ll b/LLVM_IR/demos/attachments/fac_arg.ll deleted file mode 100644 index 5b427590b..000000000 --- a/LLVM_IR/demos/attachments/fac_arg.ll +++ /dev/null @@ -1,225 +0,0 @@ -;! @.str = global [4 x i8] c"%d\0A\00", align 1 -;! declare i32 @printf(ptr , ...) - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @char2int(ptr %0, i32 %1) { - %3 = alloca ptr, align 8 - %4 = alloca i32, align 4 - %5 = alloca i32, align 4 - %6 = alloca i32, align 4 - store ptr %0, ptr %3, align 8 - store i32 %1, ptr %4, align 4 - store i32 0, ptr %5, align 4 - store i32 1, ptr %6, align 4 - %7 = load i32, ptr %4, align 4 - %8 = icmp slt i32 %7, 0 - br i1 %8, label %9, label %12 - -9: ; preds = %2 - %10 = load i32, ptr %4, align 4 - %11 = sub nsw i32 0, %10 - br label %14 - -12: ; preds = %2 - %13 = load i32, ptr %4, align 4 - br label %14 - -14: ; preds = %12, %9 - %15 = phi i32 [ %11, %9 ], [ %13, %12 ] - store i32 %15, ptr %4, align 4 - br label %16 - -16: ; preds = %78, %48, %14 - %17 = load i32, ptr %4, align 4 - %18 = add nsw i32 %17, -1 - store i32 %18, ptr %4, align 4 - %19 = icmp ne i32 %17, 0 - br i1 %19, label %20, label %79 - -20: ; preds = %16 - %21 = load ptr, ptr %3, align 8 - %22 = load i32, ptr %4, align 4 - %23 = sext i32 %22 to i64 - %24 = getelementptr i8, ptr %21, i64 %23 - %25 = load i8, ptr %24, align 1 - %26 = sext i8 %25 to i32 - %27 = icmp slt i32 %26, 48 - br i1 %27, label %36, label %28 - -28: ; preds = %20 - %29 = load ptr, ptr %3, align 8 - %30 = load i32, ptr %4, align 4 - %31 = sext i32 %30 to i64 - %32 = getelementptr i8, ptr %29, i64 %31 - %33 = load i8, ptr %32, align 1 - %34 = sext i8 %33 to i32 - %35 = icmp sgt i32 %34, 57 - br i1 %35, label %36, label %49 - -36: ; preds = %28, %20 - %37 = load ptr, ptr %3, align 8 - %38 = load i32, ptr %4, align 4 - %39 = sext i32 %38 to i64 - %40 = getelementptr i8, ptr %37, i64 %39 - %41 = load i8, ptr %40, align 1 - %42 = sext i8 %41 to i32 - %43 = icmp ne i32 %42, 45 - br i1 %43, label %44, label %49 - -44: ; preds = %36 - %45 = load i32, ptr %5, align 4 - %46 = icmp ne i32 %45, 0 - br i1 %46, label %47, label %48 - -47: ; preds = %44 - br label %79 - -48: ; preds = %44 - br label %16 - -49: ; preds = %36, %28 - %50 = load ptr, ptr %3, align 8 - %51 = load i32, ptr %4, align 4 - %52 = sext i32 %51 to i64 - %53 = getelementptr i8, ptr %50, i64 %52 - %54 = load i8, ptr %53, align 1 - %55 = sext i8 %54 to i32 - %56 = icmp eq i32 %55, 45 - br i1 %56, label %57, label %64 - -57: ; preds = %49 - %58 = load i32, ptr %5, align 4 - %59 = icmp ne i32 %58, 0 - br i1 %59, label %60, label %63 - -60: ; preds = %57 - %61 = load i32, ptr %5, align 4 - %62 = sub nsw i32 0, %61 - store i32 %62, ptr %5, align 4 - br label %79 - -63: ; preds = %57 - br label %78 - -64: ; preds = %49 - %65 = load ptr, ptr %3, align 8 - %66 = load i32, ptr %4, align 4 - %67 = sext i32 %66 to i64 - %68 = getelementptr i8, ptr %65, i64 %67 - %69 = load i8, ptr %68, align 1 - %70 = sext i8 %69 to i32 - %71 = sub nsw i32 %70, 48 - %72 = load i32, ptr %6, align 4 - %73 = mul nsw i32 %71, %72 - %74 = load i32, ptr %5, align 4 - %75 = add nsw i32 %74, %73 - store i32 %75, ptr %5, align 4 - %76 = load i32, ptr %6, align 4 - %77 = mul nsw i32 %76, 10 - store i32 %77, ptr %6, align 4 - br label %78 - -78: ; preds = %64, %63 - br label %16 - -79: ; preds = %60, %47, %16 - %80 = load i32, ptr %5, align 4 - ret i32 %80 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @mystrlen(ptr %0) { - %2 = alloca ptr, align 8 - %3 = alloca i32, align 4 - store ptr %0, ptr %2, align 8 - store i32 0, ptr %3, align 4 - br label %4 - -4: ; preds = %12, %1 - %5 = load ptr, ptr %2, align 8 - %6 = load i32, ptr %3, align 4 - %7 = add nsw i32 %6, 1 - store i32 %7, ptr %3, align 4 - %8 = sext i32 %6 to i64 - %9 = getelementptr i8, ptr %5, i64 %8 - %10 = load i8, ptr %9, align 1 - %11 = icmp ne i8 %10, 0 - br i1 %11, label %12, label %13 - -12: ; preds = %4 - br label %4 - -13: ; preds = %4 - %14 = load i32, ptr %3, align 4 - ret i32 %14 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @fac(i32 %0) { - %2 = alloca i32, align 4 - %3 = alloca i32, align 4 - store i32 %0, ptr %3, align 4 - %4 = load i32, ptr %3, align 4 - %5 = icmp slt i32 %4, 1 - br i1 %5, label %6, label %7 - -6: ; preds = %1 - store i32 1, ptr %2, align 4 - br label %13 - -7: ; preds = %1 - %8 = load i32, ptr %3, align 4 - %9 = sub nsw i32 %8, 1 - %10 = call i32 @fac(i32 %9) - %11 = load i32, ptr %3, align 4 - %12 = mul nsw i32 %10, %11 - store i32 %12, ptr %2, align 4 - br label %13 - -13: ; preds = %7, %6 - %14 = load i32, ptr %2, align 4 - ret i32 %14 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @main(i32 %0, ptr %1) { - %3 = alloca i32, align 4 - %4 = alloca i32, align 4 - %5 = alloca ptr, align 8 - %6 = alloca ptr, align 8 - %7 = alloca i32, align 4 - %8 = alloca i32, align 4 - store i32 0, ptr %3, align 4 - store i32 %0, ptr %4, align 4 - store ptr %1, ptr %5, align 8 - %9 = load i32, ptr %4, align 4 - %10 = icmp sgt i32 %9, 1 - br i1 %10, label %11, label %22 - -11: ; preds = %2 - %12 = load ptr, ptr %5, align 8 - %13 = getelementptr ptr, ptr %12, i64 1 - %14 = load ptr, ptr %13, align 8 - store ptr %14, ptr %6, align 8 - %15 = load ptr, ptr %6, align 8 - %16 = call i32 @mystrlen(ptr %15) - store i32 %16, ptr %7, align 4 - %17 = load ptr, ptr %6, align 8 - %18 = load i32, ptr %7, align 4 - %19 = call i32 @char2int(ptr %17, i32 %18) - store i32 %19, ptr %8, align 4 - %20 = load i32, ptr %8, align 4 - %21 = call i32 @fac(i32 %20) - store i32 %21, ptr %3, align 4 - br label %23 - -22: ; preds = %2 - store i32 0, ptr %3, align 4 - br label %23 - -23: ; preds = %22, %11 - %24 = load i32, ptr %3, align 4 - ;! %print_res = call i32 (ptr, ...) @printf(ptr @.str, i32 %24) - ;! ret i32 0 - ret i32 %24 -} \ No newline at end of file diff --git a/LLVM_IR/demos/attachments/simple_ssa_fail.ll b/LLVM_IR/demos/attachments/simple_ssa_fail.ll deleted file mode 100644 index 3437dcfd6..000000000 --- a/LLVM_IR/demos/attachments/simple_ssa_fail.ll +++ /dev/null @@ -1,4 +0,0 @@ -define i32 @plusplus(i32 %arg) { - %arg = add i32 %arg, 1 - ret i32 %arg -} \ No newline at end of file diff --git a/LLVM_IR/demos/attachments/sum_args.ll b/LLVM_IR/demos/attachments/sum_args.ll deleted file mode 100644 index e68be9a49..000000000 --- a/LLVM_IR/demos/attachments/sum_args.ll +++ /dev/null @@ -1,208 +0,0 @@ -;! @.str = global [4 x i8] c"%d\0A\00", align 1 -;! declare i32 @printf(ptr , ...) - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @char2int(ptr %c0, i32 %c1) { - %c3 = alloca ptr, align 8 - %c4 = alloca i32, align 4 - %c5 = alloca i32, align 4 - %c6 = alloca i32, align 4 - store ptr %c0, ptr %c3, align 8 - store i32 %c1, ptr %c4, align 4 - store i32 0, ptr %c5, align 4 - store i32 1, ptr %c6, align 4 - %c7 = load i32, ptr %c4, align 4 - %c8 = icmp slt i32 %c7, 0 - br i1 %c8, label %c9, label %c12 - -c9: ; preds = %2 - %c10 = load i32, ptr %c4, align 4 - %c11 = sub nsw i32 0, %c10 - br label %c14 - -c12: ; preds = %2 - %c13 = load i32, ptr %c4, align 4 - br label %c14 - -c14: ; preds = %c12, %9 - %c15 = phi i32 [ %c11, %c9 ], [ %c13, %c12 ] - store i32 %c15, ptr %c4, align 4 - br label %c16 - -c16: ; preds = %c78, %c48, %c14 - %c17 = load i32, ptr %c4, align 4 - %c18 = add nsw i32 %c17, -1 - store i32 %c18, ptr %c4, align 4 - %c19 = icmp ne i32 %c17, 0 - br i1 %c19, label %c20, label %c79 - -c20: ; preds = %c16 - %c21 = load ptr, ptr %c3, align 8 - %c22 = load i32, ptr %c4, align 4 - %c23 = sext i32 %c22 to i64 - %c24 = getelementptr i8, ptr %c21, i64 %c23 - %c25 = load i8, ptr %c24, align 1 - %c26 = sext i8 %c25 to i32 - %c27 = icmp slt i32 %c26, 48 - br i1 %c27, label %c36, label %c28 - -c28: ; preds = %c20 - %c29 = load ptr, ptr %c3, align 8 - %c30 = load i32, ptr %c4, align 4 - %c31 = sext i32 %c30 to i64 - %c32 = getelementptr i8, ptr %c29, i64 %c31 - %c33 = load i8, ptr %c32, align 1 - %c34 = sext i8 %c33 to i32 - %c35 = icmp sgt i32 %c34, 57 - br i1 %c35, label %c36, label %c49 - -c36: ; preds = %c28, %c20 - %c37 = load ptr, ptr %c3, align 8 - %c38 = load i32, ptr %c4, align 4 - %c39 = sext i32 %c38 to i64 - %c40 = getelementptr i8, ptr %c37, i64 %c39 - %c41 = load i8, ptr %c40, align 1 - %c42 = sext i8 %c41 to i32 - %c43 = icmp ne i32 %c42, 45 - br i1 %c43, label %c44, label %c49 - -c44: ; preds = %c36 - %c45 = load i32, ptr %c5, align 4 - %c46 = icmp ne i32 %c45, 0 - br i1 %c46, label %c47, label %c48 - -c47: ; preds = %c44 - br label %c79 - -c48: ; preds = %c44 - br label %c16 - -c49: ; preds = %c36, %c28 - %c50 = load ptr, ptr %c3, align 8 - %c51 = load i32, ptr %c4, align 4 - %c52 = sext i32 %c51 to i64 - %c53 = getelementptr i8, ptr %c50, i64 %c52 - %c54 = load i8, ptr %c53, align 1 - %c55 = sext i8 %c54 to i32 - %c56 = icmp eq i32 %c55, 45 - br i1 %c56, label %c57, label %c64 - -c57: ; preds = %c49 - %c58 = load i32, ptr %c5, align 4 - %c59 = icmp ne i32 %c58, 0 - br i1 %c59, label %c60, label %c63 - -c60: ; preds = %c57 - %c61 = load i32, ptr %c5, align 4 - %c62 = sub nsw i32 0, %c61 - store i32 %c62, ptr %c5, align 4 - br label %c79 - -c63: ; preds = %c57 - br label %c78 - -c64: ; preds = %c49 - %c65 = load ptr, ptr %c3, align 8 - %c66 = load i32, ptr %c4, align 4 - %c67 = sext i32 %c66 to i64 - %c68 = getelementptr i8, ptr %c65, i64 %c67 - %c69 = load i8, ptr %c68, align 1 - %c70 = sext i8 %c69 to i32 - %c71 = sub nsw i32 %c70, 48 - %c72 = load i32, ptr %c6, align 4 - %c73 = mul nsw i32 %c71, %c72 - %c74 = load i32, ptr %c5, align 4 - %c75 = add nsw i32 %c74, %c73 - store i32 %c75, ptr %c5, align 4 - %c76 = load i32, ptr %c6, align 4 - %c77 = mul nsw i32 %c76, 10 - store i32 %c77, ptr %c6, align 4 - br label %c78 - -c78: ; preds = %c64, %c63 - br label %c16 - -c79: ; preds = %c60, %c47, %c16 - %c80 = load i32, ptr %c5, align 4 - ret i32 %c80 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @mystrlen(ptr %s0) { - %s2 = alloca ptr, align 8 - %s3 = alloca i32, align 4 - store ptr %s0, ptr %s2, align 8 - store i32 0, ptr %s3, align 4 - br label %s4 - -s4: ; preds = %s12, %1 - %s5 = load ptr, ptr %s2, align 8 - %s6 = load i32, ptr %s3, align 4 - %s7 = add nsw i32 %s6, 1 - store i32 %s7, ptr %s3, align 4 - %s8 = sext i32 %s6 to i64 - %s9 = getelementptr i8, ptr %s5, i64 %s8 - %s10 = load i8, ptr %s9, align 1 - %s11 = icmp ne i8 %s10, 0 - br i1 %s11, label %s12, label %s13 - -s12: ; preds = %4 - br label %s4 - -s13: ; preds = %4 - %s14 = load i32, ptr %s3, align 4 - ret i32 %s14 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @main(i32 %a0, ptr %a1){ - %a3 = alloca i32, align 4 - %a4 = alloca i32, align 4 - %a5 = alloca ptr, align 8 - %a6 = alloca i32, align 4 - %a7 = alloca i32, align 4 - %a8 = alloca ptr, align 8 - %a9 = alloca i32, align 4 - store i32 0, ptr %a3, align 4 - store i32 %a0, ptr %a4, align 4 - store ptr %a1, ptr %a5, align 8 - store i32 0, ptr %a6, align 4 - store i32 0, ptr %a7, align 4 - br label %a10 - -a10: ; preds = %a27, %2 - %a11 = load i32, ptr %a7, align 4 - %a12 = load i32, ptr %a4, align 4 - %a13 = icmp slt i32 %a11, %a12 - br i1 %a13, label %a14, label %a30 - -a14: ; preds = %a10 - %a15 = load ptr, ptr %a5, align 8 - %a16 = load i32, ptr %a7, align 4 - %a17 = sext i32 %a16 to i64 - %a18 = getelementptr ptr, ptr %a15, i64 %a17 - %a19 = load ptr, ptr %a18, align 8 - store ptr %a19, ptr %a8, align 8 - %a20 = load ptr, ptr %a8, align 8 - %a21 = call i32 @mystrlen(ptr %a20) - store i32 %a21, ptr %a9, align 4 - %a22 = load ptr, ptr %a8, align 8 - %a23 = load i32, ptr %a9, align 4 - %a24 = call i32 @char2int(ptr %a22, i32 %a23) - %a25 = load i32, ptr %a6, align 4 - %a26 = add nsw i32 %a25, %a24 - store i32 %a26, ptr %a6, align 4 - br label %a27 - -a27: ; preds = %a14 - %a28 = load i32, ptr %a7, align 4 - %a29 = add nsw i32 %a28, 1 - store i32 %a29, ptr %a7, align 4 - br label %a10 - -a30: ; preds = %a10 - %a31 = load i32, ptr %a6, align 4 - ;! %print_res = call i32 (ptr, ...) @printf(ptr @.str, i32 %a31) - ;! ret i32 0 - ret i32 %a31 -} diff --git a/LLVM_IR/demos/attachments/test.ll b/LLVM_IR/demos/attachments/test.ll deleted file mode 100644 index 4786d638d..000000000 --- a/LLVM_IR/demos/attachments/test.ll +++ /dev/null @@ -1,23 +0,0 @@ -@dd = global i32 0, align 4 -@bb = global i32 32, align 4 - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @ds() { - %1 = alloca i32, align 4 - store i32 5, ptr %1, align 4 - %2 = load i32, ptr %1, align 4 - %3 = load i32, ptr @bb, align 4 - %4 = add nsw i32 %3, %2 - store i32 %4, ptr @bb, align 4 - %5 = load i32, ptr @dd, align 4 - store i32 %5, ptr %1, align 4 - %6 = load i32, ptr %1, align 4 - ret i32 %6 -} - -; Function Attrs: noinline nounwind optnone uwtable -define i32 @main(){ - %1 = call i32 @ds() - %2 = call i32 @ds() - ret i32 0 -} diff --git a/LLVM_IR/demos/attachments/triangle_square.ll b/LLVM_IR/demos/attachments/triangle_square.ll deleted file mode 100644 index 3cb6f2b62..000000000 --- a/LLVM_IR/demos/attachments/triangle_square.ll +++ /dev/null @@ -1,284 +0,0 @@ -;! @.str = global [4 x i8] c"%f\0A\00", align 1 -;! declare i32 @printf(ptr , ...) - -; Function Attrs: noinline nounwind optnone uwtable - - -define float @llvm.fmuladd.f32(float %a, float %b, float %c){ - %d = fmul float %a, %b - %r = fadd float %d, %c - ret float %r -} - - -define float @custom_atof(ptr %0) { - %2 = alloca ptr, align 8 - %3 = alloca float, align 4 - %4 = alloca i32, align 4 - %5 = alloca i32, align 4 - %6 = alloca float, align 4 - store ptr %0, ptr %2, align 8 - store float 0.000000e+00, ptr %3, align 4 - store i32 0, ptr %4, align 4 - store i32 1, ptr %5, align 4 - store float 1.000000e+00, ptr %6, align 4 - %7 = load ptr, ptr %2, align 8 - %8 = getelementptr i8, ptr %7, i64 0 - %9 = load i8, ptr %8, align 1 - %10 = sext i8 %9 to i32 - %11 = icmp eq i32 %10, 45 - br i1 %11, label %12, label %15 - -12: ; preds = %1 - store i32 -1, ptr %5, align 4 - %13 = load i32, ptr %4, align 4 - %14 = add nsw i32 %13, 1 - store i32 %14, ptr %4, align 4 - br label %15 - -15: ; preds = %12, %1 - br label %16 - -16: ; preds = %45, %15 - %17 = load ptr, ptr %2, align 8 - %18 = load i32, ptr %4, align 4 - %19 = sext i32 %18 to i64 - %20 = getelementptr i8, ptr %17, i64 %19 - %21 = load i8, ptr %20, align 1 - %22 = sext i8 %21 to i32 - %23 = icmp ne i32 %22, 46 - br i1 %23, label %24, label %32 - -24: ; preds = %16 - %25 = load ptr, ptr %2, align 8 - %26 = load i32, ptr %4, align 4 - %27 = sext i32 %26 to i64 - %28 = getelementptr i8, ptr %25, i64 %27 - %29 = load i8, ptr %28, align 1 - %30 = sext i8 %29 to i32 - %31 = icmp ne i32 %30, 0 - br label %32 - -32: ; preds = %24, %16 - %33 = phi i1 [ false, %16 ], [ %31, %24 ] - br i1 %33, label %34, label %48 - -34: ; preds = %32 - %35 = load float, ptr %3, align 4 - %36 = load ptr, ptr %2, align 8 - %37 = load i32, ptr %4, align 4 - %38 = sext i32 %37 to i64 - %39 = getelementptr i8, ptr %36, i64 %38 - %40 = load i8, ptr %39, align 1 - %41 = sext i8 %40 to i32 - %42 = sub nsw i32 %41, 48 - %43 = sitofp i32 %42 to float - %44 = call float @llvm.fmuladd.f32(float %35, float 1.000000e+01, float %43) - store float %44, ptr %3, align 4 - br label %45 - -45: ; preds = %34 - %46 = load i32, ptr %4, align 4 - %47 = add nsw i32 %46, 1 - store i32 %47, ptr %4, align 4 - br label %16 - -48: ; preds = %32 - %49 = load ptr, ptr %2, align 8 - %50 = load i32, ptr %4, align 4 - %51 = sext i32 %50 to i64 - %52 = getelementptr i8, ptr %49, i64 %51 - %53 = load i8, ptr %52, align 1 - %54 = sext i8 %53 to i32 - %55 = icmp eq i32 %54, 46 - br i1 %55, label %56, label %59 - -56: ; preds = %48 - %57 = load i32, ptr %4, align 4 - %58 = add nsw i32 %57, 1 - store i32 %58, ptr %4, align 4 - br label %59 - -59: ; preds = %56, %48 - br label %60 - -60: ; preds = %81, %59 - %61 = load ptr, ptr %2, align 8 - %62 = load i32, ptr %4, align 4 - %63 = sext i32 %62 to i64 - %64 = getelementptr i8, ptr %61, i64 %63 - %65 = load i8, ptr %64, align 1 - %66 = sext i8 %65 to i32 - %67 = icmp ne i32 %66, 0 - br i1 %67, label %68, label %84 - -68: ; preds = %60 - %69 = load float, ptr %3, align 4 - %70 = load ptr, ptr %2, align 8 - %71 = load i32, ptr %4, align 4 - %72 = sext i32 %71 to i64 - %73 = getelementptr i8, ptr %70, i64 %72 - %74 = load i8, ptr %73, align 1 - %75 = sext i8 %74 to i32 - %76 = sub nsw i32 %75, 48 - %77 = sitofp i32 %76 to float - %78 = call float @llvm.fmuladd.f32(float %69, float 1.000000e+01, float %77) - store float %78, ptr %3, align 4 - %79 = load float, ptr %6, align 4 - %80 = fmul float %79, 1.000000e+01 - store float %80, ptr %6, align 4 - br label %81 - -81: ; preds = %68 - %82 = load i32, ptr %4, align 4 - %83 = add nsw i32 %82, 1 - store i32 %83, ptr %4, align 4 - br label %60 - -84: ; preds = %60 - %85 = load i32, ptr %5, align 4 - %86 = sitofp i32 %85 to float - %87 = load float, ptr %3, align 4 - %88 = fmul float %86, %87 - %89 = load float, ptr %6, align 4 - %90 = fdiv float %88, %89 - ret float %90 -} - - -; Function Attrs: noinline nounwind optnone uwtable -define float @my_fabs(float %0) { - %2 = alloca float, align 4 - store float %0, ptr %2, align 4 - %3 = load float, ptr %2, align 4 - %4 = fcmp olt float %3, 0.000000e+00 - br i1 %4, label %5, label %8 - -5: ; preds = %1 - %6 = load float, ptr %2, align 4 - %7 = fneg float %6 - store float %7, ptr %2, align 4 - br label %8 - -8: ; preds = %5, %1 - %9 = load float, ptr %2, align 4 - ret float %9 -} - -; Function Attrs: noinline nounwind optnone uwtable -define float @findArea(<2 x float> %0, <2 x float> %1, <2 x float> %2) { - %4 = alloca{float, float}, align 4 - %5 = alloca{float, float}, align 4 - %6 = alloca{float, float}, align 4 - store <2 x float> %0, ptr %4, align 4 - store <2 x float> %1, ptr %5, align 4 - store <2 x float> %2, ptr %6, align 4 - %7 = getelementptr {float, float}, ptr %4, i32 0, i32 0 - %8 = load float, ptr %7, align 4 - %9 = getelementptr {float, float}, ptr %5, i32 0, i32 1 - %10 = load float, ptr %9, align 4 - %11 = getelementptr {float, float}, ptr %6, i32 0, i32 1 - %12 = load float, ptr %11, align 4 - %13 = fsub float %10, %12 - %14 = getelementptr {float, float}, ptr %5, i32 0, i32 0 - %15 = load float, ptr %14, align 4 - %16 = getelementptr {float, float}, ptr %6, i32 0, i32 1 - %17 = load float, ptr %16, align 4 - %18 = getelementptr {float, float}, ptr %4, i32 0, i32 1 - %19 = load float, ptr %18, align 4 - %20 = fsub float %17, %19 - %21 = fmul float %15, %20 - %22 = call float @llvm.fmuladd.f32(float %8, float %13, float %21) - %23 = getelementptr {float, float}, ptr %6, i32 0, i32 0 - %24 = load float, ptr %23, align 4 - %25 = getelementptr {float, float}, ptr %4, i32 0, i32 1 - %26 = load float, ptr %25, align 4 - %27 = getelementptr {float, float}, ptr %5, i32 0, i32 1 - %28 = load float, ptr %27, align 4 - %29 = fsub float %26, %28 - %30 = call float @llvm.fmuladd.f32(float %24, float %29, float %22) - %31 = fdiv float %30, 2.000000e+00 - %32 = call float @my_fabs(float %31) - ret float %32 -} - -; Function Attrs: noinline nounwind optnone uwtable -define float @main(i32 %0, ptr %1) { - %3 = alloca i32, align 4 - %4 = alloca ptr, align 8 - %5 = alloca [3 x{float, float}], align 16 - %6 = alloca i32, align 4 - %7 = alloca float, align 4 - %8 = alloca float, align 4 - %9 = alloca float, align 4 - store i32 %0, ptr %3, align 4 - store ptr %1, ptr %4, align 8 - %10 = load i32, ptr %3, align 4 - %11 = icmp sgt i32 %10, 6 - br i1 %11, label %12, label %47 - -12: ; preds = %2 - store i32 0, ptr %6, align 4 - br label %13 - -13: ; preds = %43, %12 - %14 = load i32, ptr %6, align 4 - %15 = icmp slt i32 %14, 3 - br i1 %15, label %16, label %46 - -16: ; preds = %13 - %17 = load ptr, ptr %4, align 8 - %18 = load i32, ptr %6, align 4 - %19 = mul nsw i32 %18, 2 - %20 = add nsw i32 1, %19 - %21 = sext i32 %20 to i64 - %22 = getelementptr ptr, ptr %17, i64 %21 - %23 = load ptr, ptr %22, align 8 - %24 = call float @custom_atof(ptr %23) - store float %24, ptr %7, align 4 - %25 = load ptr, ptr %4, align 8 - %26 = load i32, ptr %6, align 4 - %27 = mul nsw i32 %26, 2 - %28 = add nsw i32 %27, 2 - %29 = sext i32 %28 to i64 - %30 = getelementptr ptr, ptr %25, i64 %29 - %31 = load ptr, ptr %30, align 8 - %32 = call float @custom_atof(ptr %31) - store float %32, ptr %8, align 4 - %33 = load float, ptr %7, align 4 - %34 = load i32, ptr %6, align 4 - %35 = sext i32 %34 to i64 - %36 = getelementptr [3 x{float, float}], ptr %5, i64 0, i64 %35 - %37 = getelementptr {float, float}, ptr %36, i32 0, i32 0 - store float %33, ptr %37, align 8 - %38 = load float, ptr %8, align 4 - %39 = load i32, ptr %6, align 4 - %40 = sext i32 %39 to i64 - %41 = getelementptr [3 x{float, float}], ptr %5, i64 0, i64 %40 - %42 = getelementptr {float, float}, ptr %41, i32 0, i32 1 - store float %38, ptr %42, align 4 - br label %43 - -43: ; preds = %16 - %44 = load i32, ptr %6, align 4 - %45 = add nsw i32 %44, 1 - store i32 %45, ptr %6, align 4 - br label %13 - -46: ; preds = %13 - br label %47 - -47: ; preds = %46, %2 - %48 = getelementptr [3 x{float, float}], ptr %5, i64 0, i64 0 - %49 = getelementptr [3 x{float, float}], ptr %5, i64 0, i64 1 - %50 = getelementptr [3 x{float, float}], ptr %5, i64 0, i64 2 - %51 = load <2 x float>, ptr %48, align 16 - %52 = load <2 x float>, ptr %49, align 8 - %53 = load <2 x float>, ptr %50, align 16 - %54 = call float @findArea(<2 x float> %51, <2 x float> %52, <2 x float> %53) - store float %54, ptr %9, align 4 - %55 = load float, ptr %9, align 4 - ;! %fd = fpext float %55 to double - ;! %print_res = call i32 (ptr, ...) @printf(ptr @.str, double %fd) - ret float %55 -} diff --git a/LLVM_IR/demos/attachments/vec_sum_args.ll b/LLVM_IR/demos/attachments/vec_sum_args.ll deleted file mode 100644 index e9601e1da..000000000 --- a/LLVM_IR/demos/attachments/vec_sum_args.ll +++ /dev/null @@ -1,255 +0,0 @@ - -;! @.str = global [11 x i8] c"%d %d %d \0A\00", align 1 -;! declare i32 @printf(ptr , ...) - - -; Function Attrsa: noinline nounwind optnone uwtable -define i32 @char2int(ptr %a0, i32 %a1) { - %a3 = alloca ptr, align 8 - %a4 = alloca i32, align 4 - %a5 = alloca i32, align 4 - %a6 = alloca i32, align 4 - store ptr %a0, ptr %a3, align 8 - store i32 %a1, ptr %a4, align 4 - store i32 0, ptr %a5, align 4 - store i32 1, ptr %a6, align 4 - %a7 = load i32, ptr %a4, align 4 - %a8 = icmp slt i32 %a7, 0 - br i1 %a8, label %a9, label %a12 - -a9: ; preds = %a2 - %a10 = load i32, ptr %a4, align 4 - %a11 = sub nsw i32 0, %a10 - br label %a14 - -a12: ; preds = %a2 - %a13 = load i32, ptr %a4, align 4 - br label %a14 - -a14: ; preds = %a12, %a9 - %a15 = phi i32 [ %a11, %a9 ], [ %a13, %a12 ] - store i32 %a15, ptr %a4, align 4 - br label %a16 - -a16: ; preds = %a78, %a48, %a14 - %a17 = load i32, ptr %a4, align 4 - %a18 = add nsw i32 %a17, -1 - store i32 %a18, ptr %a4, align 4 - %a19 = icmp ne i32 %a17, 0 - br i1 %a19, label %a20, label %a79 - -a20: ; preds = %a16 - %a21 = load ptr, ptr %a3, align 8 - %a22 = load i32, ptr %a4, align 4 - %a23 = sext i32 %a22 to i64 - %a24 = getelementptr i8, ptr %a21, i64 %a23 - %a25 = load i8, ptr %a24, align 1 - %a26 = sext i8 %a25 to i32 - %a27 = icmp slt i32 %a26, 48 - br i1 %a27, label %a36, label %a28 - -a28: ; preds = %a20 - %a29 = load ptr, ptr %a3, align 8 - %a30 = load i32, ptr %a4, align 4 - %a31 = sext i32 %a30 to i64 - %a32 = getelementptr i8, ptr %a29, i64 %a31 - %a33 = load i8, ptr %a32, align 1 - %a34 = sext i8 %a33 to i32 - %a35 = icmp sgt i32 %a34, 57 - br i1 %a35, label %a36, label %a49 - -a36: ; preds = %a28, %a20 - %a37 = load ptr, ptr %a3, align 8 - %a38 = load i32, ptr %a4, align 4 - %a39 = sext i32 %a38 to i64 - %a40 = getelementptr i8, ptr %a37, i64 %a39 - %a41 = load i8, ptr %a40, align 1 - %a42 = sext i8 %a41 to i32 - %a43 = icmp ne i32 %a42, 45 - br i1 %a43, label %a44, label %a49 - -a44: ; preds = %a36 - %a45 = load i32, ptr %a5, align 4 - %a46 = icmp ne i32 %a45, 0 - br i1 %a46, label %a47, label %a48 - -a47: ; preds = %a44 - br label %a79 - -a48: ; preds = %a44 - br label %a16 - -a49: ; preds = %a36, %a28 - %a50 = load ptr, ptr %a3, align 8 - %a51 = load i32, ptr %a4, align 4 - %a52 = sext i32 %a51 to i64 - %a53 = getelementptr i8, ptr %a50, i64 %a52 - %a54 = load i8, ptr %a53, align 1 - %a55 = sext i8 %a54 to i32 - %a56 = icmp eq i32 %a55, 45 - br i1 %a56, label %a57, label %a64 - -a57: ; preds = %a49 - %a58 = load i32, ptr %a5, align 4 - %a59 = icmp ne i32 %a58, 0 - br i1 %a59, label %a60, label %a63 - -a60: ; preds = %a57 - %a61 = load i32, ptr %a5, align 4 - %a62 = sub nsw i32 0, %a61 - store i32 %a62, ptr %a5, align 4 - br label %a79 - -a63: ; preds = %a57 - br label %a78 - -a64: ; preds = %a49 - %a65 = load ptr, ptr %a3, align 8 - %a66 = load i32, ptr %a4, align 4 - %a67 = sext i32 %a66 to i64 - %a68 = getelementptr i8, ptr %a65, i64 %a67 - %a69 = load i8, ptr %a68, align 1 - %a70 = sext i8 %a69 to i32 - %a71 = sub nsw i32 %a70, 48 - %a72 = load i32, ptr %a6, align 4 - %a73 = mul nsw i32 %a71, %a72 - %a74 = load i32, ptr %a5, align 4 - %a75 = add nsw i32 %a74, %a73 - store i32 %a75, ptr %a5, align 4 - %a76 = load i32, ptr %a6, align 4 - %a77 = mul nsw i32 %a76, 10 - store i32 %a77, ptr %a6, align 4 - br label %a78 - -a78: ; preds = %a64, %a63 - br label %a16 - -a79: ; preds = %a60, %a47, %a16 - %a80 = load i32, ptr %a5, align 4 - ret i32 %a80 -} - -; Function Attrsa: noinline nounwind optnone uwtable -define i32 @mystrlen(ptr %a0) { - %a2 = alloca ptr, align 8 - %a3 = alloca i32, align 4 - store ptr %a0, ptr %a2, align 8 - store i32 0, ptr %a3, align 4 - br label %a4 - -a4: ; preds = %a12, %a1 - %a5 = load ptr, ptr %a2, align 8 - %a6 = load i32, ptr %a3, align 4 - %a7 = add nsw i32 %a6, 1 - store i32 %a7, ptr %a3, align 4 - %a8 = sext i32 %a6 to i64 - %a9 = getelementptr i8, ptr %a5, i64 %a8 - %a10 = load i8, ptr %a9, align 1 - %a11 = icmp ne i8 %a10, 0 - br i1 %a11, label %a12, label %a13 - -a12: ; preds = %a4 - br label %a4 - -a13: ; preds = %a4 - %a14 = load i32, ptr %a3, align 4 - ret i32 %a14 -} - -; Function Attrsa: noinline nounwind optnone uwtable -define <3 x i32> @main(i32 %a0, ptr %a1) { -a2: - %a3 = alloca i32, align 4 - %a4 = alloca ptr, align 8 - %a5 = alloca i32, align 4 - %a6 = alloca i32, align 4 - %a8 = alloca <3 x i32>, align 4 - %a9 = alloca i32, align 4 - %a10 = alloca ptr, align 8 - %a11 = alloca i32, align 4 - store i32 %a0, ptr %a3, align 4 - store ptr %a1, ptr %a4, align 8 - store i32 0, ptr %a5, align 4 - store i32 0, ptr %a6, align 4 - %vector_a1 = insertelement <3 x i32> , i32 0, i32 0 - %vector_a2 = insertelement <3 x i32> %vector_a1, i32 0, i32 1 - %vector_a3 = insertelement <3 x i32> %vector_a2, i32 0, i32 2 - %a15 = load i32, ptr %a3, align 4 - %a16 = sub nsw i32 %a15, 1 - %a17 = srem i32 %a16, 3 - %a18 = icmp eq i32 %a17, 0 - br i1 %a18, label %a19, label %a71 - -a19: ; preds = %a2 - br label %a20 - ; while -a20: ; preds = %a67, %a19 - %vec_a_iter = phi <3 x i32> [%vector_a3, %a19], [%vec_a_new, %a67] - %a21 = load i32, ptr %a6, align 4 - %a22 = mul nsw i32 %a21, 3 - %a23 = add nsw i32 %a22, 1 - %a24 = load i32, ptr %a3, align 4 - %a25 = icmp slt i32 %a23, %a24 - br i1 %a25, label %a26, label %a70 - -a26: ; preds = %a20 - store i32 0, ptr %a9, align 4 - br label %a27 - -a27: ; preds = %a47, %a26 - %vector_b = phi <3 x i32> [, %a26], [%vector_b_new, %a47] - %a28 = load i32, ptr %a9, align 4 - %a29 = icmp slt i32 %a28, 3 - br i1 %a29, label %a30, label %a50 - -a30: ; preds = %a27 - %a31 = load ptr, ptr %a4, align 8 - %a32 = load i32, ptr %a6, align 4 - %a33 = mul nsw i32 %a32, 3 - %a34 = add nsw i32 1, %a33 - %a35 = load i32, ptr %a9, align 4 - %a36 = add nsw i32 %a34, %a35 - %a37 = sext i32 %a36 to i64 - %a38 = getelementptr ptr, ptr %a31, i64 %a37 - %a39 = load ptr, ptr %a38, align 8 - store ptr %a39, ptr %a10, align 8 - %a40 = load ptr, ptr %a10, align 8 - %a41 = load ptr, ptr %a10, align 8 - %a42 = call i32 @mystrlen(ptr %a41) - %a43 = call i32 @char2int(ptr %a40, i32 %a42) - %a44 = load i32, ptr %a9, align 4 - %a45 = sext i32 %a44 to i64 - %vector_b_new = insertelement <3 x i32> %vector_b, i32 %a43, i64 %a45 - br label %a47 - -a47: ; preds = %a30 - %a48 = load i32, ptr %a9, align 4 - %a49 = add nsw i32 %a48, 1 - store i32 %a49, ptr %a9, align 4 - br label %a27 - -a50: ; preds = %a27 - store i32 0, ptr %a11, align 4 - br label %a51 - -a51: ; preds = %a64, %a50 - %vec_a_new = add nsw <3 x i32> %vector_b, %vec_a_iter - br label %a67 - -a67: ; preds = %a51 - %a68 = load i32, ptr %a6, align 4 - %a69 = add nsw i32 %a68, 1 - store i32 %a69, ptr %a6, align 4 - br label %a20 - -a70: ; preds = %a20 - br label %a71 - -a71: ; preds = %a70, %a2 - %vector_a_fin = phi <3 x i32> [%vector_a3, %a2], [%vec_a_iter, %a70] - ;! %va0 = extractelement <3 x i32> %vector_a_fin, i64 0 - ;! %va1 = extractelement <3 x i32> %vector_a_fin, i64 1 - ;! %va2 = extractelement <3 x i32> %vector_a_fin, i64 2 - ;! %a78 = call i32 (ptr, ...) @printf(ptr @.str, i32 %va0, i32 %va1, i32 %va2) - ret <3 x i32> %vector_a_fin -} diff --git a/LLVM_IR/demos/demoInterpret.ml b/LLVM_IR/demos/demoInterpret.ml deleted file mode 100644 index b9e1bc533..000000000 --- a/LLVM_IR/demos/demoInterpret.ml +++ /dev/null @@ -1,8 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - Main.interpretate_programm s -;; diff --git a/LLVM_IR/demos/demoParse.ml b/LLVM_IR/demos/demoParse.ml deleted file mode 100644 index f1827153c..000000000 --- a/LLVM_IR/demos/demoParse.ml +++ /dev/null @@ -1,10 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Parser.Parsing.parse_program s with - | Result.Ok lst -> Format.printf "%s" (Ast.show_glob_list lst) - | Error e -> Format.printf "Error: %s" e -;; diff --git a/LLVM_IR/demos/dune b/LLVM_IR/demos/dune deleted file mode 100644 index 1b67f6aec..000000000 --- a/LLVM_IR/demos/dune +++ /dev/null @@ -1,78 +0,0 @@ -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries parser stdio)) - -(executable - (name demoInterpret) - (modules demoInterpret) - (public_name demoInterpret) - (libraries main stdio)) - -(rule - (target sum_args_patched.ll) - (deps ./attachments/sum_args.ll) - (action - (system "sed 's/;!//' %{deps} > %{target}"))) - -(rule - (target sum_args.elf) - (deps sum_args_patched.ll) - (action - (system "clang-15 %{deps} -o %{target}"))) - -(rule - (target fac_arg_patched.ll) - (deps ./attachments/fac_arg.ll) - (action - (system "sed 's/;!//' %{deps} > %{target}"))) - -(rule - (target fac_arg.elf) - (deps fac_arg_patched.ll) - (action - (system "clang-15 %{deps} -o %{target}"))) - -(rule - (target triangle_square_patched.ll) - (deps ./attachments/triangle_square.ll) - (action - (system "sed 's/;!//' %{deps} > %{target}"))) - -(rule - (target triangle_square.elf) - (deps triangle_square_patched.ll) - (action - (system "clang-15 %{deps} -o %{target}"))) - -(rule - (target vec_sum_args_patched.ll) - (deps ./attachments/vec_sum_args.ll) - (action - (system "sed 's/;!//' %{deps} > %{target}"))) - -(rule - (target vec_sum_args.elf) - (deps vec_sum_args_patched.ll) - (action - (system "clang-15 %{deps} -o %{target}"))) - -(cram - (applies_to parsingTests) - (deps ./demoParse.exe ./attachments/fac.ll ./attachments/test.ll)) - -(cram - (applies_to interpretTests) - (deps - ./demoInterpret.exe - ./attachments/simple_ssa_fail.ll - ./attachments/fac.ll - ./attachments/sum_args.ll - sum_args.elf - ./attachments/triangle_square.ll - triangle_square.elf - ./attachments/fac_arg.ll - fac_arg.elf - ./attachments/vec_sum_args.ll - vec_sum_args.elf)) diff --git a/LLVM_IR/demos/interpretTests.t b/LLVM_IR/demos/interpretTests.t deleted file mode 100644 index 3f3d4d4cb..000000000 --- a/LLVM_IR/demos/interpretTests.t +++ /dev/null @@ -1,87 +0,0 @@ -Copyright 2023-2024, Efremov Alexey -SPDX-License-Identifier: CC0-1.0 - - $ ./demoInterpret.exe < ./attachments/simple_ssa_fail.ll - SSA check failed: - Variable arg already was assigned - - $ ./demoInterpret.exe < ./attachments/fac.ll - Programm return: - (CInteger (32, 120L)) - - $ ./demoInterpret.exe 2000 20 4 < ./attachments/sum_args.ll - Programm return: - (CInteger (32, 2024L)) - - $ ./sum_args.elf 2000 20 4 - 2024 - - $ ./demoInterpret.exe 2000 -1000 30337 1 1 1 1 1 < ./attachments/sum_args.ll - Programm return: - (CInteger (32, 31342L)) - - $ ./sum_args.elf 2000 -1000 30337 1 1 1 1 1 - 31342 - - - $ ./demoInterpret.exe 12.0 0.0 0. 0. 0. 12. < ./attachments/triangle_square.ll - Programm return: - (CFloat 72.) - - $ ./triangle_square.elf 12.0 0.0 0.0 0.0 0.0 12.0 - 72.000000 - [10] - - $ ./demoInterpret.exe 0.012 0. 0. 0. 0. 0.012 < ./attachments/triangle_square.ll - Programm return: - (CFloat 7.2e-05) - - $ ./triangle_square.elf 0.012 0. 0. 0. 0. 0.012 - 0.000072 - [9] - - $ ./demoInterpret.exe 1 < ./attachments/fac_arg.ll - Programm return: - (CInteger (32, 1L)) - - $ ./fac_arg.elf 1 - 1 - - $ ./demoInterpret.exe 2 < ./attachments/fac_arg.ll - Programm return: - (CInteger (32, 2L)) - - $ ./fac_arg.elf 1 - 1 - - $ ./demoInterpret.exe 6 < ./attachments/fac_arg.ll - Programm return: - (CInteger (32, 720L)) - - $ ./fac_arg.elf 6 - 720 - - $ ./demoInterpret.exe 10 < ./attachments/fac_arg.ll - Programm return: - (CInteger (32, 3628800L)) - - $ ./fac_arg.elf 10 - 3628800 - - $ ./demoInterpret.exe 111 222 333 888 666 777 < ./attachments/vec_sum_args.ll - Programm return: - (CVector - [(CInteger (32, 999L)); (CInteger (32, 888L)); (CInteger (32, 1110L))]) - - $ ./vec_sum_args.elf 111 222 333 888 666 777 - 999 888 1110 - [14] - - $ ./demoInterpret.exe 1 2 3 4 5 6 7 8 9 < ./attachments/vec_sum_args.ll - Programm return: - (CVector [(CInteger (32, 12L)); (CInteger (32, 15L)); (CInteger (32, 18L))]) - - $ ./vec_sum_args.elf 1 2 3 4 5 6 7 8 9 - 12 15 18 - [10] - diff --git a/LLVM_IR/demos/parsingTests.t b/LLVM_IR/demos/parsingTests.t deleted file mode 100644 index 616297f80..000000000 --- a/LLVM_IR/demos/parsingTests.t +++ /dev/null @@ -1,170 +0,0 @@ -Copyright 2023-2024, Efremov Alexey -SPDX-License-Identifier: CC0-1.0 - - $ ./demoParse.exe < ./attachments/fac.ll - [((TFunc ((TInteger 32), [(TInteger 32)])), (GlobalVar "fac"), - (CFunc - { ftp = (TFunc ((TInteger 32), [(TInteger 32)])); - parameters = [(LocalVar "0")]; - basic_blocks = - [((LocalVar ""), - (CLabel - [(MemoryAddress - (Alloca ((LocalVar "2"), (TInteger 32), - (Const (CInteger (1, 1L))), 4))); - (MemoryAddress - (Alloca ((LocalVar "3"), (TInteger 32), - (Const (CInteger (1, 1L))), 4))); - (MemoryAddress - (Store ((TInteger 32), - (FromVariable ((LocalVar "0"), (TInteger 32))), - (FromVariable ((LocalVar "3"), TPointer)), 4))); - (MemoryAddress - (Load ((LocalVar "4"), (TInteger 32), - (FromVariable ((LocalVar "3"), TPointer)), 4))); - (Other - (Icmp ((LocalVar "5"), "slt", (TInteger 32), - (FromVariable ((LocalVar "4"), (TInteger 32))), - (Const (CInteger (32, 1L)))))); - (Terminator - (BrCond ((FromVariable ((LocalVar "5"), (TInteger 1))), - (FromVariable ((LocalVar "6"), TLabel)), - (FromVariable ((LocalVar "7"), TLabel))))) - ])); - ((LocalVar "6"), - (CLabel - [(MemoryAddress - (Store ((TInteger 32), (Const (CInteger (32, 1L))), - (FromVariable ((LocalVar "2"), TPointer)), 4))); - (Terminator (Br (FromVariable ((LocalVar "13"), TLabel))))])); - ((LocalVar "7"), - (CLabel - [(MemoryAddress - (Load ((LocalVar "8"), (TInteger 32), - (FromVariable ((LocalVar "3"), TPointer)), 4))); - (Binary - (Sub - ((LocalVar "9"), (TInteger 32), - (FromVariable ((LocalVar "8"), (TInteger 32))), - (Const (CInteger (32, 1L)))))); - (Other - (Call ((LocalVar "10"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "fac")))), - [(FromVariable ((LocalVar "9"), (TInteger 32)))]))); - (MemoryAddress - (Load ((LocalVar "11"), (TInteger 32), - (FromVariable ((LocalVar "3"), TPointer)), 4))); - (Binary - (Mul - ((LocalVar "12"), (TInteger 32), - (FromVariable ((LocalVar "10"), (TInteger 32))), - (FromVariable ((LocalVar "11"), (TInteger 32)))))); - (MemoryAddress - (Store ((TInteger 32), - (FromVariable ((LocalVar "12"), (TInteger 32))), - (FromVariable ((LocalVar "2"), TPointer)), 4))); - (Terminator (Br (FromVariable ((LocalVar "13"), TLabel))))])); - ((LocalVar "13"), - (CLabel - [(MemoryAddress - (Load ((LocalVar "14"), (TInteger 32), - (FromVariable ((LocalVar "2"), TPointer)), 4))); - (Terminator - (Ret ((TInteger 32), - (FromVariable ((LocalVar "14"), (TInteger 32)))))) - ])) - ] - }), - 1); - ((TFunc ((TInteger 32), [])), (GlobalVar "main"), - (CFunc - { ftp = (TFunc ((TInteger 32), [])); parameters = []; - basic_blocks = - [((LocalVar ""), - (CLabel - [(MemoryAddress - (Alloca ((LocalVar "1"), (TInteger 32), - (Const (CInteger (1, 1L))), 4))); - (MemoryAddress - (Store ((TInteger 32), (Const (CInteger (32, 0L))), - (FromVariable ((LocalVar "1"), TPointer)), 4))); - (Other - (Call ((LocalVar "2"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "fac")))), - [(Const (CInteger (32, 5L)))]))); - (Terminator - (Ret ((TInteger 32), - (FromVariable ((LocalVar "2"), (TInteger 32)))))) - ])) - ] - }), - 1) - ] - - $ ./demoParse.exe < ./attachments/test.ll - [((TInteger 32), (GlobalVar "dd"), (CInteger (32, 0L)), 4); - ((TInteger 32), (GlobalVar "bb"), (CInteger (32, 32L)), 4); - ((TFunc ((TInteger 32), [])), (GlobalVar "ds"), - (CFunc - { ftp = (TFunc ((TInteger 32), [])); parameters = []; - basic_blocks = - [((LocalVar ""), - (CLabel - [(MemoryAddress - (Alloca ((LocalVar "1"), (TInteger 32), - (Const (CInteger (1, 1L))), 4))); - (MemoryAddress - (Store ((TInteger 32), (Const (CInteger (32, 5L))), - (FromVariable ((LocalVar "1"), TPointer)), 4))); - (MemoryAddress - (Load ((LocalVar "2"), (TInteger 32), - (FromVariable ((LocalVar "1"), TPointer)), 4))); - (MemoryAddress - (Load ((LocalVar "3"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "bb")))), 4))); - (Binary - (Add - ((LocalVar "4"), (TInteger 32), - (FromVariable ((LocalVar "3"), (TInteger 32))), - (FromVariable ((LocalVar "2"), (TInteger 32)))))); - (MemoryAddress - (Store ((TInteger 32), - (FromVariable ((LocalVar "4"), (TInteger 32))), - (Const (CPointer (PointerGlob (GlobalVar "bb")))), 4))); - (MemoryAddress - (Load ((LocalVar "5"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "dd")))), 4))); - (MemoryAddress - (Store ((TInteger 32), - (FromVariable ((LocalVar "5"), (TInteger 32))), - (FromVariable ((LocalVar "1"), TPointer)), 4))); - (MemoryAddress - (Load ((LocalVar "6"), (TInteger 32), - (FromVariable ((LocalVar "1"), TPointer)), 4))); - (Terminator - (Ret ((TInteger 32), - (FromVariable ((LocalVar "6"), (TInteger 32)))))) - ])) - ] - }), - 1); - ((TFunc ((TInteger 32), [])), (GlobalVar "main"), - (CFunc - { ftp = (TFunc ((TInteger 32), [])); parameters = []; - basic_blocks = - [((LocalVar ""), - (CLabel - [(Other - (Call ((LocalVar "1"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "ds")))), - []))); - (Other - (Call ((LocalVar "2"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "ds")))), - []))); - (Terminator (Ret ((TInteger 32), (Const (CInteger (32, 0L)))))) - ])) - ] - }), - 1) - ] diff --git a/LLVM_IR/dune b/LLVM_IR/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/LLVM_IR/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/LLVM_IR/dune-project b/LLVM_IR/dune-project deleted file mode 100644 index 26f1555ab..000000000 --- a/LLVM_IR/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Efremov Alexey") - -(maintainers "Efremov Alexey") - -(bug_reports "https://github.com/Kakadu/fp2023/issues") - -(homepage "https://github.com/Kakadu/fp2023/tree/master/LLVM_IR") - -(package - (name LLVM_IR) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "An interpreter for LLVM Intermediate Representation") - (description - "An interpreter for LLVM Intermediate Representation with interesting features, also known as bugs") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/LLVM_IR/lib/afterParseCheck/dune b/LLVM_IR/lib/afterParseCheck/dune deleted file mode 100644 index f8b717abc..000000000 --- a/LLVM_IR/lib/afterParseCheck/dune +++ /dev/null @@ -1,9 +0,0 @@ -(library - (name checks) - (public_name LLVM_IR.Checks) - (libraries ast common parser base ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/LLVM_IR/lib/afterParseCheck/ssaCheck.ml b/LLVM_IR/lib/afterParseCheck/ssaCheck.ml deleted file mode 100644 index bcb90cf75..000000000 --- a/LLVM_IR/lib/afterParseCheck/ssaCheck.ml +++ /dev/null @@ -1,157 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -include Common.StateMonad - -module MapString = struct - include Map.Make (String) - - let pp pp_v ppf m = - Format.fprintf ppf "@[[@["; - iter (fun k v -> Format.fprintf ppf "@[\"%S\": %a@],@\n" k pp_v v) m; - Format.fprintf ppf "@]]@]" - ;; -end - -type map_var = bool MapString.t [@@deriving show { with_path = false }] -type state = map_var * map_var - -let check_var : Ast.variable -> (state, unit) t = - let find_var : string -> map_var -> (state, unit) t = - fun name map -> - let value = MapString.find_opt name map in - match value with - | Some _ -> fail (Printf.sprintf "Variable %s already was assigned" name) - | None -> return () - in - fun variable -> - let* local, glob = read in - match variable with - | Ast.GlobalVar name -> find_var name glob - | Ast.LocalVar name -> find_var name local -;; - -let write_var : Ast.variable -> state -> (state, unit) t = - fun key (old_local, old_global) -> - match key with - | Ast.GlobalVar name -> write (old_local, MapString.add name true old_global) - | Ast.LocalVar name -> write (MapString.add name true old_local, old_global) -;; - -let try_add_var : Ast.variable -> (state, unit) t = - fun var -> - check_var var - *> - let* st = read in - write_var var st -;; - -let ssa_instruction : Ast.instruction -> (state, unit) t = - let terminator = function - | _ -> return () - and unary = function - | Ast.Fneg (var, _, _) -> try_add_var var - and binary = function - | Ast.Add body - | Ast.Fadd body - | Ast.Mul body - | Ast.Fmul body - | Ast.Sub body - | Ast.Fsub body - | Ast.Udiv body - | Ast.Sdiv body - | Ast.Fdiv body - | Ast.Urem body - | Ast.Srem body - | Ast.Frem body -> - let var, _, _, _ = body in - try_add_var var - and bitwise = function - | Ast.Shl body - | Ast.Lshr body - | Ast.Ashr body - | Ast.And body - | Ast.Or body - | Ast.Xor body -> - let var, _, _, _ = body in - try_add_var var - and vector = function - | Ast.Extractelement (var, _, _, _, _) - | Ast.Insertelement (var, _, _, _, _, _) - | Ast.Shufflevector (var, _, _, _, _, _) -> try_add_var var - and aggregate = function - | Ast.Extractvalue (var, _, _, _) | Ast.Insertvalue (var, _, _, _, _, _) -> - try_add_var var - and memory = function - | Ast.Alloca (var, _, _, _) - | Ast.Load (var, _, _, _) - | Ast.Getelementptr (var, _, _, _, _) -> try_add_var var - | Ast.Store _ -> return () - and conversion = function - | Ast.TruncTo body - | Ast.ZextTo body - | Ast.SextTo body - | Ast.FptouiTo body - | Ast.FptosiTo body - | Ast.UitofpTo body - | Ast.SitofpTo body - | Ast.PrttointTo body - | Ast.InttoprtTo body -> - let var, _, _, _ = body in - try_add_var var - and other = function - | Ast.Icmp (var, _, _, _, _) - | Ast.Fcmp (var, _, _, _, _) - | Ast.Phi (var, _, _) - | Ast.Select (var, _, _, _, _, _) - | Ast.Call (var, _, _, _) -> try_add_var var - in - function - | Terminator inst -> terminator inst - | Unary inst -> unary inst - | Binary inst -> binary inst - | BitwiseBinary inst -> bitwise inst - | Vector inst -> vector inst - | Aggregate inst -> aggregate inst - | MemoryAddress inst -> memory inst - | Conversion inst -> conversion inst - | Other inst -> other inst -;; - -let ssa_block_var : Ast.variable * Ast.const -> (state, unit) t = - fun (var, block) -> - try_add_var var - *> - match block with - | Ast.CLabel inst_lst -> map_list ssa_instruction inst_lst *> return () - | _ -> fail "Impossible error: get not block in block const" -;; - -let ssa_fnc : Ast.func -> (state, unit) t = - fun fnc -> - let* old_st = read in - let _old_loc, old_glob = old_st in - let new_st = MapString.empty, old_glob in - let* _ = write new_st in - let* _check_args = map_list try_add_var fnc.parameters in - let* _check_blocks = map_list ssa_block_var fnc.basic_blocks in - write old_st *> return () -;; - -let ssa_glob_list : Ast.glob_list -> (state, unit) t = - fun glob_lst -> - let ssa_glob_elem (_, var, value, _) = - try_add_var var - *> - match value with - | Ast.CFunc fnc -> ssa_fnc fnc - | _ -> return () - in - map_list ssa_glob_elem glob_lst *> return () -;; - -let run_ssa_glob_list glob_lst = - let _, res = run (ssa_glob_list glob_lst) (MapString.empty, MapString.empty) in - res -;; diff --git a/LLVM_IR/lib/afterParseCheck/ssaCheck.mli b/LLVM_IR/lib/afterParseCheck/ssaCheck.mli deleted file mode 100644 index ca1019be9..000000000 --- a/LLVM_IR/lib/afterParseCheck/ssaCheck.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val run_ssa_glob_list : Ast.glob_list -> (unit, string) result diff --git a/LLVM_IR/lib/afterParseCheck/test.ml b/LLVM_IR/lib/afterParseCheck/test.ml deleted file mode 100644 index abac795a3..000000000 --- a/LLVM_IR/lib/afterParseCheck/test.ml +++ /dev/null @@ -1,118 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open SsaCheck - -let test_ssa str = - match Parser.Parsing.parse_program str with - | Result.Error s -> Printf.printf "Parser error: \n %s" s - | Result.Ok glob_lst -> - (match run_ssa_glob_list glob_lst with - | Result.Ok _ -> Printf.printf "Pass" - | Result.Error s -> Printf.printf "SSA check failed: \n %s" s) -;; - -let%expect_test _ = - test_ssa " %res = fcmp one float 4.0, 5.0"; - [%expect {| - Parser error: - : end_of_input |}] -;; - -let%expect_test _ = - test_ssa - {| @dd = global i32 0, align 4 - @bb = global i32 32, align 4 - @cc = global i32 32, align 4 - @aa = global i32 32, align 4 |}; - [%expect {| - Pass |}] -;; - -let%expect_test _ = - test_ssa {| @bb = global i32 0, align 4 - @bb = global i32 32, align 4 |}; - [%expect {| - SSA check failed: - Variable bb already was assigned |}] -;; - -let%expect_test _ = - test_ssa - {| @bb = global i32 0, align 4 - define i32 @bb(){ - %1 = call i32 @ds() - %2 = call i32 @ds() - ret i32 0 - } |}; - [%expect {| - SSA check failed: - Variable bb already was assigned |}] -;; - -let%expect_test _ = - test_ssa "@dd = global i32 0, align 4\ndefine i32 @bb(i32 %0, i32 %1){ ret i32 0 }"; - [%expect {| - Pass |}] -;; - -let%expect_test _ = - test_ssa - "@dd = global i32 0, align 4\ndefine i32 @bb(i32 %0, i32 %1, i35 %0){ret i32 0}"; - [%expect {| - SSA check failed: - Variable 0 already was assigned |}] -;; - -let%expect_test _ = - test_ssa - {| define i32 @ds() { - %1 = alloca i32, align 4 - store i32 5, ptr %1, align 4 - %2 = load i32, ptr %1, align 4 - %3 = load i32, ptr @bb, align 4 - %4 = add nsw i32 %3, %2 - store i32 %4, ptr @bb, align 4 - %5 = load i32, ptr @dd, align 4 - store i32 %5, ptr %1, align 4 - %6 = load i32, ptr %1, align 4 - ret i32 %6 - } |}; - [%expect {| - Pass |}] -;; - -let%expect_test _ = - test_ssa - {| define i32 @ds(i32 %6) { - %1 = alloca i32, align 4 - store i32 5, ptr %1, align 4 - %2 = load i32, ptr %1, align 4 - %3 = load i32, ptr @bb, align 4 - %4 = add nsw i32 %3, %2 - store i32 %4, ptr @bb, align 4 - %5 = load i32, ptr @dd, align 4 - store i32 %5, ptr %1, align 4 - %6 = load i32, ptr %1, align 4 - ret i32 %6 - } |}; - [%expect {| - SSA check failed: - Variable 6 already was assigned |}] -;; - -let%expect_test _ = - test_ssa - {| define i32 @d1(i32 %0) { - %1 = alloca i32, align 4 - ret i32 %6 - } - - define i32 @d2(i32 %0) { - %1 = alloca i32, align 4 - ret i32 %6 - } |}; - [%expect {| - Pass |}] -;; diff --git a/LLVM_IR/lib/afterParseCheck/test.mli b/LLVM_IR/lib/afterParseCheck/test.mli deleted file mode 100644 index 74280436f..000000000 --- a/LLVM_IR/lib/afterParseCheck/test.mli +++ /dev/null @@ -1,3 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) diff --git a/LLVM_IR/lib/ast/ast.ml b/LLVM_IR/lib/ast/ast.ml deleted file mode 100644 index a65c0e4a8..000000000 --- a/LLVM_IR/lib/ast/ast.ml +++ /dev/null @@ -1,204 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -type tp = - (* only for function ret*) - | TVoid (** void *) - (* primitive types*) - | TFloat (** float *) - | TInteger of int (** i1, i2 ... in *) - | TPointer (** ptr *) - (* first class types*) - | TVector of int * tp (** *) - | TArr of int * tp (** [int x type] *) - | TStruct of tp list (** \{type1, type2...\} *) - (* additional types*) - | TLabel (** label *) - | TFunc of tp * tp list (** () *) -(* - | Token - | Metadata -*) -[@@deriving show { with_path = false }, eq] - -type variable = - | LocalVar of string (** %name *) - | GlobalVar of string (** \@name *) -[@@deriving show { with_path = false }] - -type pointer_const = - | PointerGlob of variable - | PointerInt of int -[@@deriving show { with_path = false }] - -type align = int (* just for better reading*) [@@deriving show { with_path = false }] - -type const = - | CVoid - | CInteger of int * Int64.t (** size and value*) - | CFloat of float - | CPointer of pointer_const - | CVector of const list (** *) - | CArr of const list (** [const, const, ...] *) - | CStruct of const list (** \{const, const, ...\} *) - | CLabel of basic_block - | CFunc of func -[@@deriving show { with_path = false }] - -and value = - | FromVariable of variable * tp - | Const of const -[@@deriving show { with_path = false }] - -(* ############ Instructions Start ########### *) -and terminator_instruction = - | Ret of tp * value (** ret *) - | Br of value (** br label *) - | BrCond of value * value * value (** br i1 , label , label *) - | Switch of tp * value * value * (value * value) list - (** switch , label [ , label ... ] *) - | Unreachable (** unreachable *) -[@@deriving show { with_path = false }] - -and unary_operation = Fneg of variable * tp * value (** = fneg *) -[@@deriving show { with_path = false }] - -and binary_operation_body = - variable * tp * value * value (* = , *) -[@@deriving show { with_path = false }] - -and binary_operation = - | Add of binary_operation_body - | Fadd of binary_operation_body - | Mul of binary_operation_body - | Fmul of binary_operation_body - | Sub of binary_operation_body - | Fsub of binary_operation_body - | Udiv of binary_operation_body - | Sdiv of binary_operation_body - | Fdiv of binary_operation_body - | Urem of binary_operation_body - | Srem of binary_operation_body - | Frem of binary_operation_body -[@@deriving show { with_path = false }] - -and bitwise_binary_operation = - | Shl of binary_operation_body - | Lshr of binary_operation_body - | Ashr of binary_operation_body - | And of binary_operation_body - | Or of binary_operation_body - | Xor of binary_operation_body -[@@deriving show { with_path = false }] - -and vector_instruction = - | Extractelement of variable * tp * value * tp * value - (** = extractelement > , *) - | Insertelement of variable * tp * value * value * tp * value - (** = insertelement > , , *) - | Shufflevector of variable * tp * value * value * int * const - (** = shufflevector > , > , *) -[@@deriving show { with_path = false }] - -and aggregate_instruction = - | Extractvalue of variable * tp * value * int list - (** = extractvalue , \{, \}* *) - | Insertvalue of variable * tp * value * tp * value * int list - (** = insertvalue , , \{, \}* *) - -and memory_address_instruction = - | Alloca of variable * tp * value * align - (** = alloca [, ] [, align ] *) - | Store of tp * value * value * align - (** store , ptr [, align ] *) - | Load of variable * tp * value * align - (** = load , ptr [, align ]*) - | Getelementptr of variable * tp * tp * value * (tp * value) list - (** = getelementptr , \{, \}* *) - -(** = to *) -and conversion_instruction_body = variable * tp * value * tp - -and conversion_instruction = - | TruncTo of conversion_instruction_body - | ZextTo of conversion_instruction_body - | SextTo of conversion_instruction_body - | FptouiTo of conversion_instruction_body - | FptosiTo of conversion_instruction_body - | UitofpTo of conversion_instruction_body - | SitofpTo of conversion_instruction_body - | PrttointTo of conversion_instruction_body - | InttoprtTo of conversion_instruction_body - -and other_operation = - | Icmp of variable * string * tp * value * value - (** = icmp , *) - | Fcmp of variable * string * tp * value * value - (** = fcmp , *) - | Phi of variable * tp * (value * value) list - (** = phi [ , ], ... *) - | Select of variable * tp * value * tp * value * value - (** = select , , *) - | Call of variable * tp * value * value list - (** = call () *) - -and instruction = - | Terminator of terminator_instruction - | Unary of unary_operation - | Binary of binary_operation - | BitwiseBinary of bitwise_binary_operation - | Vector of vector_instruction - | Aggregate of aggregate_instruction - | Other of other_operation - | MemoryAddress of memory_address_instruction - | Conversion of conversion_instruction -[@@deriving show { with_path = true }] -(* ############ Instructions End ########### *) - -and basic_block = instruction list [@@deriving show { with_path = false }] - -and func = - { ftp : tp - ; parameters : variable list - ; basic_blocks : (variable * const) list - } -[@@deriving show { with_path = false }] - -type glob_list = (tp * variable * const * int) list -[@@deriving show { with_path = false }] - -let rec const_to_tp : const -> tp = function - | CVoid -> TVoid - | CInteger (size, _) -> TInteger size - | CFloat _ -> TFloat - | CPointer _ -> TPointer - | CVector lst -> - (match lst with - | h :: _ -> TVector (List.length lst, const_to_tp h) - | [] -> TVector (List.length lst, TVoid)) - | CArr lst -> - (match lst with - | h :: _ -> TArr (List.length lst, const_to_tp h) - | [] -> TArr (List.length lst, TVoid)) - | CStruct lst -> TStruct (List.map const_to_tp lst) - | CLabel _ -> TLabel - | CFunc f -> f.ftp -;; - -let rec tp_equal : tp -> tp -> bool = - fun t1 t2 -> - match t1, t2 with - | TVoid, TVoid | TLabel, TLabel | TFloat, TFloat | TPointer, TPointer -> true - | TInteger x1, TInteger x2 when x1 = x2 -> true - | (TVector (n1, tp1), TVector (n2, tp2) | TArr (n1, tp1), TArr (n2, tp2)) - when n1 = n2 && tp_equal tp1 tp2 -> true - | TStruct tps1, TStruct tps2 -> List.equal tp_equal tps1 tps2 - | _ -> false -;; - -let variable_equal v1 v2 = - match v1, v2 with - | GlobalVar n1, GlobalVar n2 | LocalVar n1, LocalVar n2 -> String.equal n1 n2 - | _, _ -> false -;; diff --git a/LLVM_IR/lib/ast/dune b/LLVM_IR/lib/ast/dune deleted file mode 100644 index 7aaf68bdf..000000000 --- a/LLVM_IR/lib/ast/dune +++ /dev/null @@ -1,7 +0,0 @@ -(library - (name ast) - (public_name LLVM_IR.Ast) - (modules Ast) - (libraries ppx_show.runtime) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq))) diff --git a/LLVM_IR/lib/common/dune b/LLVM_IR/lib/common/dune deleted file mode 100644 index e01d7f3dc..000000000 --- a/LLVM_IR/lib/common/dune +++ /dev/null @@ -1,5 +0,0 @@ -(library - (name common) - (public_name LLVM_IR.Common) - (libraries ast) - (modules stateMonad irInts)) diff --git a/LLVM_IR/lib/common/irInts.ml b/LLVM_IR/lib/common/irInts.ml deleted file mode 100644 index a8bca3c64..000000000 --- a/LLVM_IR/lib/common/irInts.ml +++ /dev/null @@ -1,36 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -let cut x n = - if n >= 64 - then x - else ( - let mask = Int64.shift_right_logical Int64.max_int (63 - n) in - Int64.logand x mask) -;; - -let uget x n = cut x n - -let sget x n = - let mag = Int64.shift_left 1L (n - 1) in - let neg = not (Int64.equal (Int64.logand x mag) 0L) in - let value = cut x (n - 1) in - if neg then Int64.sub value mag else value -;; - -let create x n = Ast.CInteger (n, cut x n) - -let bin_op int_op l r = - match l, r with - | Ast.CInteger (sz1, v1), Ast.CInteger (sz2, v2) when sz1 = sz2 -> - Some (create (int_op (uget v1 sz1) (uget v2 sz2) sz1)) - | _ -> None -;; - -let sbin_op int_op l r = - match l, r with - | Ast.CInteger (sz1, v1), Ast.CInteger (sz2, v2) when sz1 = sz2 -> - Some (create (int_op (sget v1 sz1) (sget v2 sz2) sz1)) - | _ -> None -;; diff --git a/LLVM_IR/lib/common/irInts.mli b/LLVM_IR/lib/common/irInts.mli deleted file mode 100644 index e2a40eb2f..000000000 --- a/LLVM_IR/lib/common/irInts.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val uget : int64 -> int -> int64 -val sget : int64 -> int -> int64 -val create : int64 -> int -> Ast.const diff --git a/LLVM_IR/lib/common/stateMonad.ml b/LLVM_IR/lib/common/stateMonad.ml deleted file mode 100644 index 4a37b60fb..000000000 --- a/LLVM_IR/lib/common/stateMonad.ml +++ /dev/null @@ -1,52 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -type ('st, 'a) t = 'st -> 'st * ('a, string) Result.t - -let return x : _ = fun st -> st, Result.ok x -let fail err st = st, Result.error err - -let ( >>= ) : 's 'a 'b. ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t = - fun l r : _ -> - fun st -> - let st, x = l st in - match x with - | Result.Ok x -> r x st - | Result.Error s -> st, Result.error s -;; - -let read : ('st, 'st) t = fun st -> st, Result.ok st -let write : 'st -> ('st, unit) t = fun s _oldstate -> s, Result.ok () -let run : ('st, 'a) t -> 'st -> 'st * ('a, string) Result.t = fun f st -> f st -let ( let* ) = ( >>= ) -let ( *> ) l r = l >>= fun _ -> r -let ( >>| ) l r = l >>= fun x -> return (r x) -let ( <* ) l r = l >>= fun h -> r >>= fun _ -> return h - -(* let wrap_list : ('s, 'a) t list -> ('s, 'a list) t = - fun mlst st -> - let f lst res = - match lst, res st with - | Result.Ok lst, (_, Result.Ok x) -> Result.ok (x :: lst) - | _, (_, Result.Error s) -> Result.error s - | Result.Error s, _ -> Result.error s - in - st, List.fold_left f (Result.ok []) mlst - ;; *) - -let map_list : 'a 'b 's. ('a -> ('st, 'b) t) -> 'a list -> ('st, 'b list) t = - fun custom_f mlst -> - let f lst res = - let* tl = lst in - let* x = custom_f res in - return (x :: tl) - in - List.fold_left f (return []) mlst >>| List.rev -;; - -(* let map_list2 : 'a 'b 's. ('a -> 'b) -> 'a list -> ('s, 'b list) t = - fun custom_f mlst -> - let f lst res = lst >>= fun tl -> return (custom_f res :: tl) in - List.fold_left f (return []) mlst - ;; *) diff --git a/LLVM_IR/lib/common/stateMonad.mli b/LLVM_IR/lib/common/stateMonad.mli deleted file mode 100644 index eb66f55f3..000000000 --- a/LLVM_IR/lib/common/stateMonad.mli +++ /dev/null @@ -1,17 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -type ('st, 'a) t = 'st -> 'st * ('a, string) result - -val return : 'a -> 'b -> 'b * ('a, 'c) result -val fail : 'a -> 'b -> 'b * ('c, 'a) result -val ( >>= ) : ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t -val read : ('st, 'st) t -val write : 'st -> ('st, unit) t -val run : ('st, 'a) t -> 'st -> 'st * ('a, string) result -val ( let* ) : ('a, 'b) t -> ('b -> ('a, 'c) t) -> ('a, 'c) t -val ( *> ) : ('a, 'b) t -> ('a, 'c) t -> ('a, 'c) t -val ( >>| ) : ('a, 'b) t -> ('b -> 'c) -> ('a, 'c) t -val ( <* ) : ('a, 'b) t -> ('a, 'c) t -> ('a, 'b) t -val map_list : ('a -> ('st, 'b) t) -> 'a list -> ('st, 'b list) t diff --git a/LLVM_IR/lib/dune b/LLVM_IR/lib/dune deleted file mode 100644 index 8082b1247..000000000 --- a/LLVM_IR/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name main) - (public_name LLVM_IR.Main) - (modules main) - (libraries ast ihelp common parser checks interpreter base ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/LLVM_IR/lib/interpreter/dune b/LLVM_IR/lib/interpreter/dune deleted file mode 100644 index 41fecab4a..000000000 --- a/LLVM_IR/lib/interpreter/dune +++ /dev/null @@ -1,21 +0,0 @@ -(library - (name ihelp) - (public_name LLVM_IR.Ihelp) - (modules state memory serialisation) - (libraries ast common parser base ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) - -(library - (name interpreter) - (public_name LLVM_IR.Interpreter) - (modules interpreting) - (libraries ast instructions common ihelp parser base ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/LLVM_IR/lib/interpreter/instructions/aggregate.ml b/LLVM_IR/lib/interpreter/instructions/aggregate.ml deleted file mode 100644 index 77222fe37..000000000 --- a/LLVM_IR/lib/interpreter/instructions/aggregate.ml +++ /dev/null @@ -1,80 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let rec real_extract var cnst = function - | [] -> write_var var cnst - | ind :: tl -> - let* lst = is_aggregate return cnst in - if ind >= List.length lst - then fail "Runtime error: try get element outside of aggregate type" - else ( - let new_cnst = List.nth lst ind in - real_extract var new_cnst tl) -;; - -let iextractvalue var _agg_tp agg_val ints = - let* agg_const = get_const_from_value agg_val in - real_extract var agg_const ints -;; - -let aggregate_const_by_const = function - | Ast.CArr _ -> return (fun x -> Ast.CArr x) - | Ast.CStruct _ -> return (fun x -> Ast.CStruct x) - | _ -> fail "Impossible error: this function only for aggregate" -;; - -let single_insert new_val lst ind = - if ind >= List.length lst - then fail "Runtime error: try get element outside of aggregate type" - else return (List.mapi (fun c x -> if c = ind then new_val else x) lst) -;; - -let rec real_insert var new_val agg_const ints = - let* lst = is_aggregate return agg_const in - let* construct = aggregate_const_by_const agg_const in - match ints with - | [ x ] -> - let* finlst = single_insert new_val lst x in - let old_tp = Ast.const_to_tp (List.nth lst x) in - let new_tp = Ast.const_to_tp new_val in - if not (Ast.tp_equal old_tp new_tp) - then - fail - (Printf.sprintf - "Want to insert value with type %s instead of value with type %s" - (Ast.show_tp new_tp) - (Ast.show_tp old_tp)) - else return (construct finlst) - | ind :: tl -> - if ind >= List.length lst - then fail "Runtime error: try get element outside of aggregate type" - else ( - let new_cnst = List.nth lst ind in - let* new_val = real_insert var new_val new_cnst tl in - let* finlst = single_insert new_val lst ind in - return (construct finlst)) - | _ -> fail "Imposible error: got empty index list during insertvalue instruction" -;; - -let iinsertvalue var _agg_tp agg_val _v_tp v ints = - let* agg_const = get_const_from_value agg_val in - let* new_val = get_const_from_value v in - let* new_value = real_insert var new_val agg_const ints in - write_var var new_value -;; - -let launch_aggregate_instruction - : Ast.aggregate_instruction -> (state, instr_launch_res) t - = - fun instr -> - (match instr with - | Ast.Extractvalue (var, agg_tp, agg_val, ints) -> - iextractvalue var agg_tp agg_val ints - | Ast.Insertvalue (var, agg_tp, agg_val, v_tp, v, ints) -> - iinsertvalue var agg_tp agg_val v_tp v ints) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/aggregate.mli b/LLVM_IR/lib/interpreter/instructions/aggregate.mli deleted file mode 100644 index 1c27767fa..000000000 --- a/LLVM_IR/lib/interpreter/instructions/aggregate.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_aggregate_instruction - : Ast.aggregate_instruction - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/binary.ml b/LLVM_IR/lib/interpreter/instructions/binary.ml deleted file mode 100644 index 971a1f236..000000000 --- a/LLVM_IR/lib/interpreter/instructions/binary.ml +++ /dev/null @@ -1,59 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let check_div oper tp x y = - if Int64.equal 0L y then raise Division_by_zero else check_to_int oper tp x y -;; - -let real_add sz x y = Common.IrInts.create (Int64.add x y) sz -let real_mul sz x y = Common.IrInts.create (Int64.mul x y) sz -let real_sub sz x y = Common.IrInts.create (Int64.sub x y) sz -let real_udiv sz x y = Common.IrInts.create (Int64.div x y) sz -let real_urem sz x y = Common.IrInts.create (Int64.rem x y) sz - -let real_sdiv sz x y = - let x = Common.IrInts.sget x sz in - let y = Common.IrInts.sget y sz in - Common.IrInts.create (Int64.div x y) sz -;; - -let real_srem sz x y = - let x = Common.IrInts.sget x sz in - let y = Common.IrInts.sget y sz in - Common.IrInts.create (Int64.rem x y) sz -;; - -let real_fadd _tp x y = Ast.CFloat (Float.add x y) -let real_fmul _tp x y = Ast.CFloat (Float.mul x y) -let real_fsub _tp x y = Ast.CFloat (Float.sub x y) -let real_fdiv _tp x y = Ast.CFloat (Float.div x y) -let real_frem _tp x y = Ast.CFloat (Float.rem x y) - -let launch_binary_operation : Ast.binary_operation -> (state, instr_launch_res) t = - fun instr -> - (match instr with - | Ast.Add (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_add) is_int v1 v2 var - | Ast.Mul (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_mul) is_int v1 v2 var - | Ast.Sub (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_sub) is_int v1 v2 var - | Ast.Sdiv (var, tp, v1, v2) -> - write_binop_res tp (check_div real_sdiv) is_int v1 v2 var - | Ast.Srem (var, tp, v1, v2) -> - write_binop_res tp (check_div real_srem) is_int v1 v2 var - | Ast.Udiv (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_udiv) is_int v1 v2 var - | Ast.Urem (var, tp, v1, v2) -> - write_binop_res tp (check_div real_urem) is_int v1 v2 var - | Ast.Fadd (var, tp, v1, v2) -> write_binop_res tp real_fadd is_float v1 v2 var - | Ast.Fmul (var, tp, v1, v2) -> write_binop_res tp real_fmul is_float v1 v2 var - | Ast.Fdiv (var, tp, v1, v2) -> write_binop_res tp real_fdiv is_float v1 v2 var - | Ast.Frem (var, tp, v1, v2) -> write_binop_res tp real_frem is_float v1 v2 var - | Ast.Fsub (var, tp, v1, v2) -> write_binop_res tp real_fsub is_float v1 v2 var) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/binary.mli b/LLVM_IR/lib/interpreter/instructions/binary.mli deleted file mode 100644 index 9db80fb1b..000000000 --- a/LLVM_IR/lib/interpreter/instructions/binary.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_binary_operation - : Ast.binary_operation - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/bitwise.ml b/LLVM_IR/lib/interpreter/instructions/bitwise.ml deleted file mode 100644 index 4550b1b65..000000000 --- a/LLVM_IR/lib/interpreter/instructions/bitwise.ml +++ /dev/null @@ -1,36 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let real_shl sz x y = Common.IrInts.create (Int64.shift_left x (Int64.to_int y)) sz - -let real_lshr sz x y = - Common.IrInts.create (Int64.shift_right_logical x (Int64.to_int y)) sz -;; - -let real_ashr sz x y = Common.IrInts.create (Int64.shift_right x (Int64.to_int y)) sz -let real_and sz x y = Common.IrInts.create (Int64.logand x y) sz -let real_or sz x y = Common.IrInts.create (Int64.logor x y) sz -let real_xor sz x y = Common.IrInts.create (Int64.logxor x y) sz - -let launch_bitwise_operation : Ast.bitwise_binary_operation -> (state, instr_launch_res) t - = - fun instr -> - (match instr with - | Ast.Shl (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_shl) is_int v1 v2 var - | Ast.Lshr (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_lshr) is_int v1 v2 var - | Ast.Ashr (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_ashr) is_int v1 v2 var - | Ast.And (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_and) is_int v1 v2 var - | Ast.Or (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_or) is_int v1 v2 var - | Ast.Xor (var, tp, v1, v2) -> - write_binop_res tp (check_to_int real_xor) is_int v1 v2 var) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/bitwise.mli b/LLVM_IR/lib/interpreter/instructions/bitwise.mli deleted file mode 100644 index 6d70a535b..000000000 --- a/LLVM_IR/lib/interpreter/instructions/bitwise.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_bitwise_operation - : Ast.bitwise_binary_operation - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.ml b/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.ml deleted file mode 100644 index 140424803..000000000 --- a/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.ml +++ /dev/null @@ -1,123 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State - -type instr_launch_res = - | Ret of Ast.const - | Jmp of Ast.variable - | NoRes - -let to_ptr x = Ast.CPointer (Ast.PointerInt x) - -let err_type exp get = - fail (Printf.sprintf "expected %s, but get %s\n" (Ast.show_tp exp) (Ast.show_tp get)) -;; - -let err_type_c exp cnst = err_type exp (Ast.const_to_tp cnst) - -let get_const_from_value : Ast.value -> (state, Ast.const) t = function - | Ast.Const x -> return x - | Ast.FromVariable (var, exp_tp) -> - let* cnst = read_var var in - let real_tp = Ast.const_to_tp cnst in - if Ast.tp_equal real_tp exp_tp - then return cnst - else - fail - (Printf.sprintf - "Variable %s is of type %s, but %s was expected" - (Ast.show_variable var) - (Ast.show_tp real_tp) - (Ast.show_tp exp_tp)) -;; - -let is_block cnst = - match cnst with - | Ast.CLabel x -> return x - | _ -> err_type_c Ast.TLabel cnst -;; - -let is_bool cnst = - match cnst with - | Ast.CInteger (1, x) -> return (Int64.equal 1L x) - | _ -> err_type_c (Ast.TInteger 1) cnst -;; - -let is_int cnst = - match cnst with - | Ast.CInteger (_, x) -> return x - | _ -> err_type_c (Ast.TInteger 0) cnst -;; - -let is_float cnst = - match cnst with - | Ast.CFloat x -> return x - | _ -> err_type_c Ast.TFloat cnst -;; - -let rec is_ptr cnst = - match cnst with - | Ast.CPointer (Ast.PointerInt x) -> return x - | Ast.CPointer (Ast.PointerGlob x) -> read_var x >>= is_ptr - | _ -> err_type_c Ast.TPointer cnst -;; - -let is_vector is_elem cnst = - match cnst with - | Ast.CVector x -> map_list is_elem x - | c -> err_type_c (Ast.TVector (0, Ast.const_to_tp c)) cnst -;; - -let is_aggregate is_elem cnst = - match cnst with - | Ast.CArr x | Ast.CStruct x -> map_list is_elem x - | _ -> - fail - (Printf.sprintf - "Expected aggregate type, but got %s\n" - (Ast.show_tp (Ast.const_to_tp cnst))) -;; - -let vectorize1 operat is_elem value = - let* v = get_const_from_value value >>= is_vector is_elem in - return (Ast.CVector (List.map operat v)) -;; - -let vectorize2 operat is_elem v1 v2 = - let* v1 = get_const_from_value v1 >>= is_vector is_elem in - let* v2 = get_const_from_value v2 >>= is_vector is_elem in - return (Ast.CVector (List.map2 operat v1 v2)) -;; - -let launch_binary_body_operation operat is_elem x y = - let* x = get_const_from_value x >>= is_elem in - let* y = get_const_from_value y >>= is_elem in - try return (operat x y) with - | Division_by_zero -> fail "Runtime error: Division by 0" -;; - -let launch_binary_body_operation_vectorizated tp operat is_elem x y = - match tp with - | Ast.TVector (_, elem_tp) -> vectorize2 (operat elem_tp) is_elem x y - | _ -> launch_binary_body_operation (operat tp) is_elem x y -;; - -let write_binop_res tp real_add is_int v1 v2 var = - let* res = launch_binary_body_operation_vectorizated tp real_add is_int v1 v2 in - write_var var res -;; - -let check_to_int operat tp x y = - match tp with - | Ast.TInteger sz -> operat sz x y - | _ -> - let _ = Printf.printf "Impossible error: get wrong type at binary/biwise operation" in - Ast.CVoid -;; - -let get_bb_var_from_label = function - | Ast.FromVariable (x, _) -> return x - | Ast.Const _ -> fail "expected get basic block" -;; diff --git a/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.mli b/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.mli deleted file mode 100644 index 85f05e5fe..000000000 --- a/LLVM_IR/lib/interpreter/instructions/commonInterpInstructions.mli +++ /dev/null @@ -1,53 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -type instr_launch_res = - | Ret of Ast.const - | Jmp of Ast.variable - | NoRes - -val to_ptr : int -> Ast.const -val err_type : Ast.tp -> Ast.tp -> 'a -> 'a * ('b, string) result -val err_type_c : Ast.tp -> Ast.const -> 'a -> 'a * ('b, string) result -val get_const_from_value : Ast.value -> (Ihelp.State.state, Ast.const) Ihelp.State.t -val is_block : Ast.const -> 'a -> 'a * (Ast.basic_block, string) result -val is_bool : Ast.const -> 'a -> 'a * (bool, string) result -val is_int : Ast.const -> 'a -> 'a * (int64, string) result -val is_float : Ast.const -> 'a -> 'a * (float, string) result -val is_ptr : Ast.const -> (Ihelp.State.state, int) Ihelp.State.t - -val is_vector - : (Ast.const -> ('a, 'b) Ihelp.State.t) - -> Ast.const - -> ('a, 'b list) Ihelp.State.t - -val is_aggregate - : (Ast.const -> ('a, 'b) Ihelp.State.t) - -> Ast.const - -> ('a, 'b list) Ihelp.State.t - -val vectorize1 - : ('a -> Ast.const) - -> (Ast.const -> (Ihelp.State.state, 'a) Ihelp.State.t) - -> Ast.value - -> (Ihelp.State.state, Ast.const) Ihelp.State.t - -val vectorize2 - : ('a -> 'a -> Ast.const) - -> (Ast.const -> (Ihelp.State.state, 'a) Ihelp.State.t) - -> Ast.value - -> Ast.value - -> (Ihelp.State.state, Ast.const) Ihelp.State.t - -val write_binop_res - : Ast.tp - -> (Ast.tp -> 'a -> 'a -> Ast.const) - -> (Ast.const -> (Ihelp.State.state, 'a) Ihelp.State.t) - -> Ast.value - -> Ast.value - -> Ast.variable - -> (Ihelp.State.state, unit) Ihelp.State.t - -val check_to_int : (int -> 'a -> 'b -> Ast.const) -> Ast.tp -> 'a -> 'b -> Ast.const -val get_bb_var_from_label : Ast.value -> 'a -> 'a * (Ast.variable, string) result diff --git a/LLVM_IR/lib/interpreter/instructions/conversion.ml b/LLVM_IR/lib/interpreter/instructions/conversion.ml deleted file mode 100644 index 2ff122701..000000000 --- a/LLVM_IR/lib/interpreter/instructions/conversion.ml +++ /dev/null @@ -1,64 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let write_conversion_res operat is_elem s_tp_decon d_tp_decon s_tp s_val d_tp var = - let* res = - match s_tp, d_tp with - | Ast.TVector (n1, s_el_tp), Ast.TVector (n2, d_el_tp) -> - if n1 <> n2 - then fail "Source vector and destination have different size" - else vectorize1 (operat (s_tp_decon s_el_tp) (d_tp_decon d_el_tp)) is_elem s_val - | _ -> - let* v = get_const_from_value s_val >>= is_elem in - return ((operat (s_tp_decon s_tp) (d_tp_decon d_tp)) v) - in - write_var var res -;; - -let int_d = function - | Ast.TInteger sz -> sz - | _ -> - let _ = Printf.printf "Impossible error: get wrong type at conversion operation" in - -1 -;; - -let empty_d _tp = () -let real_trunc _ssz dsz x = Common.IrInts.create x dsz -let real_zext = real_trunc -let real_sext ssz dsz x = Common.IrInts.create (Common.IrInts.sget x ssz) dsz -let real_fptoui _ dsz x = Common.IrInts.create (Int64.of_float x) dsz -let real_fptosi = real_fptoui -let real_uitofp _ _ x = Ast.CFloat (Int64.to_float x) -let real_sitofp ssz _ x = Ast.CFloat (Int64.to_float (Common.IrInts.sget x ssz)) -let real_ptrtoint _ dsz x = Common.IrInts.create (Int64.of_int x) dsz -let real_inttoptr _ _ x = to_ptr (Int64.to_int x) - -let launch_conversion_instruction - : Ast.conversion_instruction -> (state, instr_launch_res) t - = - fun instr -> - (match instr with - | Ast.TruncTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_trunc is_int int_d int_d s_tp s_val d_tp var - | Ast.ZextTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_zext is_int int_d int_d s_tp s_val d_tp var - | Ast.SextTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_sext is_int int_d int_d s_tp s_val d_tp var - | Ast.FptosiTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_fptosi is_float empty_d int_d s_tp s_val d_tp var - | Ast.FptouiTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_fptoui is_float empty_d int_d s_tp s_val d_tp var - | Ast.UitofpTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_uitofp is_int int_d empty_d s_tp s_val d_tp var - | Ast.SitofpTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_sitofp is_int int_d empty_d s_tp s_val d_tp var - | Ast.PrttointTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_ptrtoint is_ptr empty_d int_d s_tp s_val d_tp var - | Ast.InttoprtTo (var, s_tp, s_val, d_tp) -> - write_conversion_res real_inttoptr is_int int_d empty_d s_tp s_val d_tp var) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/conversion.mli b/LLVM_IR/lib/interpreter/instructions/conversion.mli deleted file mode 100644 index 5626e641a..000000000 --- a/LLVM_IR/lib/interpreter/instructions/conversion.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_conversion_instruction - : Ast.conversion_instruction - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/dune b/LLVM_IR/lib/interpreter/instructions/dune deleted file mode 100644 index 88f1604e9..000000000 --- a/LLVM_IR/lib/interpreter/instructions/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name instructions) - (public_name LLVM_IR.Instructions) - (modules - aggregate - commonInterpInstructions - other - terminator - unary - binary - bitwise - vector - memoryAddress - conversion) - (libraries ast common ihelp base ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/LLVM_IR/lib/interpreter/instructions/memoryAddress.ml b/LLVM_IR/lib/interpreter/instructions/memoryAddress.ml deleted file mode 100644 index fee946958..000000000 --- a/LLVM_IR/lib/interpreter/instructions/memoryAddress.ml +++ /dev/null @@ -1,104 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp -open State -open CommonInterpInstructions - -let ialloca variable tp value align = - let* n = get_const_from_value value >>= is_int in - let sz = Int64.to_int n * Serialisation.raw_date_len tp in - let* addr = Memory.alloc_stack_align sz align in - write_var variable (to_ptr addr) -;; - -let istore _tp value ptr align = - let* value = get_const_from_value value in - let* ptr = get_const_from_value ptr >>= is_ptr in - (* if ptr mod align = 0 - then *) - Memory.put_cnst_in_heap ptr value -;; - -(* else fail "Runtime error: get unaligned pointer for store" *) - -let iload var tp ptr align = - let* ptr = get_const_from_value ptr >>= is_ptr in - (* if ptr mod align = 0 - then *) - let* cnst = Memory.take_cnst_from_heap ptr tp in - write_var var cnst -;; - -(* else fail "Runtime error: get unaligned pointer for load" *) - -let rec rec_real_getelementprt tp ptr = function - | [] -> return ptr - | x :: tl -> - let* delta_and_ntp = - match tp with - | Ast.TArr (_, el_tp) | Ast.TVector (_, el_tp) -> - return (Serialisation.raw_date_len el_tp * x, el_tp) - | Ast.TStruct tp_lst when List.length tp_lst > x -> - let f (c, acc) mtp = - if c < x then c + 1, acc + Serialisation.raw_date_len mtp else c, acc - in - let _, delt = List.fold_left f (0, 0) tp_lst in - return (delt, List.nth tp_lst x) - | _ -> fail "Runtime error: invalid getelementptr indices" - in - let delta, ntp = delta_and_ntp in - rec_real_getelementprt ntp (ptr + delta) tl -;; - -let real_getelemetptr tp ptr = function - | [] -> return (to_ptr ptr) - | x :: tl -> - let ptr = ptr + (Serialisation.raw_date_len tp * x) in - let* fin_ptr = rec_real_getelementprt tp ptr tl in - return (to_ptr fin_ptr) -;; - -let igetelementptr var v_tp ptr_tp ptr ilist = - let rec transpose = function - | [] -> [] - | [] :: xss -> transpose xss - | (x :: xs) :: xss -> - (x :: List.map List.hd xss) :: transpose (xs :: List.map List.tl xss) - in - match ptr_tp with - | Ast.TVector (_, _) -> - let f (_, b) = - get_const_from_value b >>= is_vector is_int >>| List.map Int64.to_int - in - let* ptrs = get_const_from_value ptr >>= is_vector is_ptr in - let ptr_len = List.length ptrs in - let* vec_ind = map_list f ilist in - if not (List.for_all (fun l -> ptr_len = List.length l) vec_ind) - then fail "Vectors have different size in getlementptr" - else ( - let indss = transpose vec_ind in - let cnsts = List.map2 (real_getelemetptr v_tp) ptrs indss in - let* cnst = map_list (fun s -> s >>= return) cnsts >>| fun x -> Ast.CVector x in - write_var var cnst) - | _ -> - let f (_, b) = get_const_from_value b >>= is_int >>| Int64.to_int in - let* inds = map_list f ilist in - let* ptr = get_const_from_value ptr >>= is_ptr in - let* cnst = real_getelemetptr v_tp ptr inds in - write_var var cnst -;; - -let launch_memory_address_operation - : Ast.memory_address_instruction -> (state, instr_launch_res) t - = - fun instr -> - (match instr with - | Ast.Alloca (variable, tp, value, align) -> ialloca variable tp value align - | Ast.Store (tp, value, ptr, align) -> istore tp value ptr align - | Ast.Load (var, tp, ptr, align) -> iload var tp ptr align - | Ast.Getelementptr (var, v_tp, ptr_tp, ptr, ilist) -> - igetelementptr var v_tp ptr_tp ptr ilist) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/memoryAddress.mli b/LLVM_IR/lib/interpreter/instructions/memoryAddress.mli deleted file mode 100644 index 6d189de3b..000000000 --- a/LLVM_IR/lib/interpreter/instructions/memoryAddress.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_memory_address_operation - : Ast.memory_address_instruction - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/other.ml b/LLVM_IR/lib/interpreter/instructions/other.ml deleted file mode 100644 index bab19448d..000000000 --- a/LLVM_IR/lib/interpreter/instructions/other.ml +++ /dev/null @@ -1,134 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let real_frem _tp x y = Ast.CFloat (Float.rem x y) - -let parse_icmp_mode str = - let open Common.IrInts in - match str with - | "ne" -> return (uget, [ -1; 1 ]) - | "eq" -> return (uget, [ 0 ]) - | "ugt" -> return (uget, [ 1 ]) - | "uge" -> return (uget, [ 0; 1 ]) - | "ult" -> return (uget, [ -1 ]) - | "ule" -> return (uget, [ -1; 0 ]) - | "sgt" -> return (sget, [ 1 ]) - | "sge" -> return (sget, [ 0; 1 ]) - | "slt" -> return (sget, [ -1 ]) - | "sle" -> return (sget, [ -1; 0 ]) - | _ -> fail "get unknown icmp predicate" -;; - -let real_icmp trans right_vals x y = - let x = trans x in - let y = trans y in - let res = Int64.compare x y in - match List.find_opt (fun x -> x = res) right_vals with - | Some _ -> Common.IrInts.create 1L 1 - | None -> Common.IrInts.create 0L 1 -;; - -let iicmp var com_mode tp v1 v2 = - let* buf = parse_icmp_mode com_mode in - let trans, right_vals = buf in - let* cnst = - match tp with - | Ast.TVector (_, Ast.TInteger sz) -> - vectorize2 (real_icmp (fun x -> trans x sz) right_vals) is_int v1 v2 - | Ast.TInteger sz -> - let* v1 = get_const_from_value v1 >>= is_int in - let* v2 = get_const_from_value v2 >>= is_int in - return (real_icmp (fun x -> trans x sz) right_vals v1 v2) - | tp -> fail (Printf.sprintf "icmp compare ints, not %s" (Ast.show_tp tp)) - in - write_var var cnst -;; - -let parse_fcmp_mode str = - let ord x y b = (not (Float.is_nan x)) && (not (Float.is_nan y)) && b in - let uno x y b = Float.is_nan x || Float.is_nan y || b in - match str with - | "false" -> return (ord, []) - | "oeq" -> return (ord, [ 0 ]) - | "ogt" -> return (ord, [ 1 ]) - | "oge" -> return (ord, [ 0; 1 ]) - | "olt" -> return (ord, [ -1 ]) - | "ole" -> return (ord, [ -1; 0 ]) - | "one" -> return (ord, [ -1; 1 ]) - | "ord" -> return (ord, [ -1; 0; 1 ]) - | "ueq" -> return (ord, [ 0 ]) - | "ugt" -> return (uno, [ 1 ]) - | "uge" -> return (uno, [ 0; 1 ]) - | "ult" -> return (uno, [ -1 ]) - | "ule" -> return (uno, [ -1; 0 ]) - | "une" -> return (uno, [ -1; 1 ]) - | "uno" -> return (uno, []) - | "true" -> return (uno, [ -1; 0; 1 ]) - | _ -> fail "get unknown fcmp predicate" -;; - -let real_fcmp addcmp right_vals x y = - let res = Float.compare x y in - let b = - match List.find_opt (fun x -> x = res) right_vals with - | Some _ -> true - | None -> false - in - let res = addcmp x y b in - Common.IrInts.create (Int64.of_int (Bool.to_int res)) 1 -;; - -let ifcmp var com_mode tp v1 v2 = - let* buf = parse_fcmp_mode com_mode in - let addcmp, right_vals = buf in - let* cnst = - match tp with - | Ast.TVector (_, Ast.TFloat) -> - vectorize2 (real_fcmp addcmp right_vals) is_float v1 v2 - | _ -> - let* v1 = get_const_from_value v1 >>= is_float in - let* v2 = get_const_from_value v2 >>= is_float in - return ((real_fcmp addcmp right_vals) v1 v2) - in - write_var var cnst -;; - -let iphi var _tp lst = - let f (v1, v2) = - let* v2 = get_bb_var_from_label v2 in - return (v1, v2) - in - let* lst = map_list f lst in - let* last_block = read_last_block in - let res = List.find_opt (fun (_, label) -> Ast.variable_equal label last_block) lst in - match res with - | Some (v, _) -> get_const_from_value v >>= write_var var - | None -> fail "LLVM do crash-crash (clang-17.0.3 )" -;; - -let real_select b (v1, v2) = if b then v1 else v2 - -let iselect var cond_tp cond res_tp v1 v2 = - let* v1 = get_const_from_value v1 in - let* v2 = get_const_from_value v2 in - let* res = - match cond_tp with - | Ast.TVector (n, _) -> - (match res_tp with - | Ast.TVector (m, _) when m = n -> - let* v1 = is_vector return v1 in - let* v2 = is_vector return v2 in - let vvs = List.combine v1 v2 in - let* bls = get_const_from_value cond >>= is_vector is_bool in - return (Ast.CVector (List.map2 real_select bls vvs)) - | _ -> fail "selected values for vector select must be vectors with same size") - | _ -> - let* b = get_const_from_value cond >>= is_bool in - return (real_select b (v1, v2)) - in - write_var var res -;; diff --git a/LLVM_IR/lib/interpreter/instructions/other.mli b/LLVM_IR/lib/interpreter/instructions/other.mli deleted file mode 100644 index dc3cc76bc..000000000 --- a/LLVM_IR/lib/interpreter/instructions/other.mli +++ /dev/null @@ -1,34 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val iicmp - : Ast.variable - -> string - -> Ast.tp - -> Ast.value - -> Ast.value - -> (Ihelp.State.state, unit) Ihelp.State.t - -val ifcmp - : Ast.variable - -> string - -> Ast.tp - -> Ast.value - -> Ast.value - -> (Ihelp.State.state, unit) Ihelp.State.t - -val iphi - : Ast.variable - -> 'a - -> (Ast.value * Ast.value) list - -> (Ihelp.State.state, unit) Ihelp.State.t - -val iselect - : Ast.variable - -> Ast.tp - -> Ast.value - -> Ast.tp - -> Ast.value - -> Ast.value - -> (Ihelp.State.state, unit) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/terminator.ml b/LLVM_IR/lib/interpreter/instructions/terminator.ml deleted file mode 100644 index 8fbdc7e40..000000000 --- a/LLVM_IR/lib/interpreter/instructions/terminator.ml +++ /dev/null @@ -1,63 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let real_ret res = return (Ret res) - -let iret _tp value = - let* res = get_const_from_value value in - real_ret res -;; - -let real_jmp bl = return (Jmp bl) - -let ibr label = - let* bl = get_bb_var_from_label label in - real_jmp bl -;; - -let ibrcond cond label1 label2 = - let* cond = get_const_from_value cond in - let* label1 = get_bb_var_from_label label1 in - let* label2 = get_bb_var_from_label label2 in - let* cond = is_bool cond in - if cond then real_jmp label1 else real_jmp label2 -;; - -let real_switch sw dc cases = - let case = List.find_opt (fun (x, _) -> Int64.equal x sw) cases in - match case with - | Some (_, x) -> real_jmp x - | None -> real_jmp dc -;; - -let iswitch tp switcher default_case additional_cases = - match tp with - | Ast.TInteger _ -> - let* df = get_bb_var_from_label default_case in - let* sw = get_const_from_value switcher >>= is_int in - let* cases = - map_list - (fun (v1, v2) -> - let* v1 = get_const_from_value v1 >>= is_int in - let* v2 = get_bb_var_from_label v2 in - return (v1, v2)) - additional_cases - in - real_switch sw df cases - | _ -> fail "Switch can work only with integers\n" -;; - -let launch_terminator_instruction - : Ast.terminator_instruction -> (state, instr_launch_res) t - = function - | Ast.Ret (tp, value) -> iret tp value - | Ast.Br label -> ibr label - | Ast.BrCond (cond, label1, label2) -> ibrcond cond label1 label2 - | Ast.Switch (tp, switcher, default_case, additional_cases) -> - iswitch tp switcher default_case additional_cases - | Ast.Unreachable -> fail "Launch 'unreachable' instruction" -;; diff --git a/LLVM_IR/lib/interpreter/instructions/terminator.mli b/LLVM_IR/lib/interpreter/instructions/terminator.mli deleted file mode 100644 index dd197c908..000000000 --- a/LLVM_IR/lib/interpreter/instructions/terminator.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_terminator_instruction - : Ast.terminator_instruction - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/unary.ml b/LLVM_IR/lib/interpreter/instructions/unary.ml deleted file mode 100644 index 1d0f1dc93..000000000 --- a/LLVM_IR/lib/interpreter/instructions/unary.ml +++ /dev/null @@ -1,26 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let real_fneg v = Ast.CFloat (Float.neg v) - -let ifneg var tp value = - match tp with - | Ast.TFloat -> - let* v = get_const_from_value value >>= is_float in - write_var var (real_fneg v) - | Ast.TVector (_, Ast.TFloat) -> - let* v = vectorize1 real_fneg is_float value in - write_var var v - | _ -> fail "Fneg work with floats\n" -;; - -let launch_unary_operation : Ast.unary_operation -> (state, instr_launch_res) t = - fun instr -> - (match instr with - | Ast.Fneg (variable, tp, value) -> ifneg variable tp value) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/unary.mli b/LLVM_IR/lib/interpreter/instructions/unary.mli deleted file mode 100644 index 18d772685..000000000 --- a/LLVM_IR/lib/interpreter/instructions/unary.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_unary_operation - : Ast.unary_operation - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/instructions/vector.ml b/LLVM_IR/lib/interpreter/instructions/vector.ml deleted file mode 100644 index 3e7dc9684..000000000 --- a/LLVM_IR/lib/interpreter/instructions/vector.ml +++ /dev/null @@ -1,68 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp.State -open CommonInterpInstructions - -let real_extract var vec_val ind = write_var var (List.nth vec_val ind) - -let get_data vec_val ival = - let* vec_val = get_const_from_value vec_val >>= is_vector return in - let n = List.length vec_val in - let* ind = get_const_from_value ival >>= is_int in - let ind = Int64.to_int ind in - if ind >= n - then fail "Runtime error: try get element outside of vector" - else return (vec_val, ind) -;; - -let iextractelement var _vec_tp vec_val _itp ival = - let* buf = get_data vec_val ival in - let vec_val, ind = buf in - real_extract var vec_val ind -;; - -let real_insert var vec_val ind new_val = - let new_lst = List.mapi (fun c x -> if c = ind then new_val else x) vec_val in - write_var var (Ast.CVector new_lst) -;; - -let iinsertelement var _vec_tp vec_val new_val _itp ival = - let* buf = get_data vec_val ival in - let* new_val = get_const_from_value new_val in - let vec_val, ind = buf in - real_insert var vec_val ind new_val -;; - -let real_shuffle bvec ivec var = - let len = List.length bvec in - let f n = - let n = Int64.to_int n in - if n >= len - then fail "Runtime error: try get element outside of vector" - else return (List.nth bvec n) - in - let* new_vec = map_list f ivec in - write_var var (Ast.CVector new_vec) -;; - -let ishufflevector var _vec_tp vec1 vec2 _m vec3 = - let* vec1 = get_const_from_value vec1 >>= is_vector return in - let* vec2 = get_const_from_value vec2 >>= is_vector return in - let* vec3 = is_vector is_int vec3 in - let bvec = List.append vec1 vec2 in - real_shuffle bvec vec3 var -;; - -let launch_vector_instruction : Ast.vector_instruction -> (state, instr_launch_res) t = - fun instr -> - (match instr with - | Ast.Extractelement (var, vec_tp, vec_val, itp, ival) -> - iextractelement var vec_tp vec_val itp ival - | Ast.Insertelement (var, vec_tp, vec_val, new_val, itp, ival) -> - iinsertelement var vec_tp vec_val new_val itp ival - | Ast.Shufflevector (var, vec_tp, vec1, vec2, m, vec3) -> - ishufflevector var vec_tp vec1 vec2 m vec3) - *> return NoRes -;; diff --git a/LLVM_IR/lib/interpreter/instructions/vector.mli b/LLVM_IR/lib/interpreter/instructions/vector.mli deleted file mode 100644 index 0bad88d99..000000000 --- a/LLVM_IR/lib/interpreter/instructions/vector.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val launch_vector_instruction - : Ast.vector_instruction - -> (Ihelp.State.state, CommonInterpInstructions.instr_launch_res) Ihelp.State.t diff --git a/LLVM_IR/lib/interpreter/interpreting.ml b/LLVM_IR/lib/interpreter/interpreting.ml deleted file mode 100644 index cf4b0e76a..000000000 --- a/LLVM_IR/lib/interpreter/interpreting.ml +++ /dev/null @@ -1,669 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp -open State -open Instructions -open CommonInterpInstructions - -let assign_globs : Ast.glob_list -> (state, unit) t = - fun glob_lst -> - let count_addr addr glob = - let tp, _, _, align = glob in - match tp with - | Ast.TFunc (_, _) -> addr, addr - | _ -> - let na = Memory.align_addr addr align true in - let res = na + Serialisation.raw_date_len tp in - res, na - in - let _, addrs = List.fold_left_map count_addr glob_sect glob_lst in - let addrs_and_globs = List.combine addrs glob_lst in - let assign_glob : int * (Ast.tp * Ast.variable * Ast.const * int) -> (state, unit) t = - fun (addr, glob) -> - let tp, var, value, _ = glob in - let cnst = - match tp with - | Ast.TFunc (_, _) -> value - | _ -> Ast.CPointer (Ast.PointerInt addr) - in - write_var var cnst - in - map_list assign_glob addrs_and_globs *> return () -;; - -let allocate_globs : Ast.glob_list -> (state, unit) t = - fun glob_lst -> - let alloc_glob : Ast.tp * Ast.variable * Ast.const * int -> (state, unit) t = - fun (_, var, cnst, _) -> - let* ptr_cnst = read_var var in - match ptr_cnst with - | Ast.CPointer (Ast.PointerInt x) -> Memory.put_cnst_in_heap x cnst - | _ -> return () - in - map_list alloc_glob glob_lst *> return () -;; - -let init_state : Ast.glob_list -> (state, unit) t = - fun glob_lst -> assign_globs glob_lst *> allocate_globs glob_lst -;; - -let is_fnc_tp = function - | Ast.TFunc (f_ret, f_args) -> return (f_ret, f_args) - | _ -> fail "Impossible error: function have not function type" -;; - -let check_fnc_tp (fnc : Ast.func) ret_tp args = - let arg_tps = List.map Ast.const_to_tp args in - let* bf = is_fnc_tp fnc.ftp in - let f_ret, f_args = bf in - if not (Ast.tp_equal f_ret ret_tp) - then - fail - (Printf.sprintf - "Try get %s from function with %s return" - (Ast.show_tp ret_tp) - (Ast.show_tp f_ret)) - else if not (List.equal Ast.tp_equal f_args arg_tps) - then fail "Expected other function args" - else return () -;; - -let rec icall var res_tp fnc_val params = - let* cfnc = get_const_from_value fnc_val in - let* args = map_list get_const_from_value params in - match cfnc with - | Ast.CPointer (Ast.PointerGlob x) -> - let* cns = read_var x in - (match cns with - | Ast.CFunc fnc -> - let* _ = check_fnc_tp fnc res_tp args in - let* res = launch_function fnc args in - write_var var res - | c -> fail (Printf.sprintf "Expect function got %s" (Ast.show_const c))) - | c -> fail (Printf.sprintf "Expect pointer to function got %s" (Ast.show_const c)) - -and launch_other_operation : Ast.other_operation -> (state, instr_launch_res) t = - fun instr -> - (match instr with - | Ast.Icmp (var, com_mode, tp, v1, v2) -> Other.iicmp var com_mode tp v1 v2 - | Ast.Fcmp (var, com_mode, tp, v1, v2) -> Other.ifcmp var com_mode tp v1 v2 - | Ast.Phi (var, tp, lst) -> Other.iphi var tp lst - | Ast.Select (var, cond_tp, cond, res_tp, v1, v2) -> - Other.iselect var cond_tp cond res_tp v1 v2 - | Ast.Call (var, res_tp, fnc, params) -> icall var res_tp fnc params) - *> return NoRes - -and launch_instruction : Ast.instruction -> (state, instr_launch_res) t = function - | Ast.Terminator inst -> Terminator.launch_terminator_instruction inst - | Ast.Unary inst -> Unary.launch_unary_operation inst - | Ast.Binary inst -> Binary.launch_binary_operation inst - | Ast.BitwiseBinary inst -> Bitwise.launch_bitwise_operation inst - | Ast.Vector inst -> Vector.launch_vector_instruction inst - | Ast.Aggregate inst -> Aggregate.launch_aggregate_instruction inst - | Ast.MemoryAddress inst -> MemoryAddress.launch_memory_address_operation inst - | Ast.Conversion inst -> Conversion.launch_conversion_instruction inst - | Ast.Other inst -> launch_other_operation inst - -and launch_block : Ast.variable -> (state, Ast.const) t = - fun bb_var -> - (* let _ = Printf.printf "%s\n" (Ast.show_variable bb_var) in *) - let* bb = read_var bb_var >>= is_block in - let* instr_res = map_list launch_instruction bb in - let last_instr = List.nth instr_res (List.length instr_res - 1) in - match last_instr with - | Jmp x -> write_last_block bb_var *> launch_block x - | Ret x -> return x - | NoRes -> fail "Impossible error: last instruction in block should have some result\n" - -and launch_function : Ast.func -> Ast.const list -> (state, Ast.const) t = - fun fnc params_val -> - let* old_loc, old_glb, old_heap, old_stack, old_block = read in - write (MapString.empty, old_glb, old_heap, old_stack, last_block_init) - *> - let init_var (param, cnst) = write_var param cnst in - let params_cnst = List.combine fnc.parameters params_val in - map_list init_var params_cnst - *> map_list init_var fnc.basic_blocks - *> - let fb, _ = List.hd fnc.basic_blocks in - let* res = launch_block fb in - let* bf = is_fnc_tp fnc.ftp in - let f_ret, _ = bf in - let res_tp = Ast.const_to_tp res in - (if Ast.tp_equal res_tp f_ret - then return res - else - fail - (Printf.sprintf - "Function try return %s when excpected %s" - (Ast.show_tp res_tp) - (Ast.show_tp f_ret))) - <* Memory.free_stack old_stack - <* let* _, glb, heap, stack, _ = read in - write (old_loc, glb, heap, stack, old_block) -;; - -let init_sys_args int_sz = - let argc = Common.IrInts.create (Int64.of_int (Array.length Sys.argv)) int_sz in - let lst_of_bytes = - Array.to_list - (Array.map (fun s -> List.init (String.length s) (String.get s)) Sys.argv) - in - let f bytes = - let bytes = List.append bytes [ Char.chr 0 ] in - let len = List.length bytes in - let* addr = Memory.alloc_stack_align len 1 in - Memory.put_bytes_in_heap addr bytes *> return addr - in - let* rev_addr_lst = map_list f lst_of_bytes >>| List.rev in - let f addr = - let* ptr_addr = - Memory.alloc_stack_align (Serialisation.raw_date_len Ast.TPointer) 1 - in - Memory.put_cnst_in_heap ptr_addr (to_ptr addr) *> return ptr_addr - in - let* ptrs_addr = map_list f rev_addr_lst in - let fin_addr = List.nth ptrs_addr (List.length ptrs_addr - 1) in - let argv = to_ptr fin_addr in - return [ argc; argv ] -;; - -let launch_main = - let* main = read_var (Ast.GlobalVar "main") in - match main with - (* TODO: add check for main arguments*) - | Ast.CFunc x -> - let* bf = is_fnc_tp x.ftp in - let _, param = bf in - (match param with - | [] -> launch_function x [] - | [ Ast.TInteger sz; Ast.TPointer ] -> init_sys_args sz >>= launch_function x - | _ -> fail "Can not run main with unknown signature") - | _ -> fail "Error: main is not function\n" -;; - -let interpretate_ast : Ast.glob_list -> (state, Ast.const) t = - fun glb_lst -> init_state glb_lst *> launch_main -;; - -let run_interpretate_on_ast ast = run (interpretate_ast ast) empty_state - -let interp_test str = - match Parser.Parsing.parse_program str with - | Result.Ok x -> - (match run_interpretate_on_ast x with - | _, Result.Ok x -> Printf.printf "%s\n" (Ast.show_const x) - | _, Result.Error s -> Printf.printf "Error: %s!\n" s) - | _ -> Printf.printf "Parser error\n" -;; - -let%expect_test _ = - interp_test - {| -; Function Attrs: noinline nounwind optnone uwtable -define <3 x float> @main(){ - %1 = fneg <3 x float> < float 1.2, float -3.4, float 5.6> - br label %3 - 3: - ret <3 x float> %1 -} - |}; - [%expect {| - (CVector [(CFloat -1.2); (CFloat 3.4); (CFloat -5.6)]) |}] -;; - -let%expect_test _ = - interp_test - {| -; Function Attrs: noinline nounwind optnone uwtable -define <3 x float> @main(){ - %1 = fneg <3 x float> < float 1.2, float -3.4, float 5.6> - %3 = fadd <3 x float> %1, < float 10.0, float 8.0, float 7.0> - ret <3 x float> %3 -} - |}; - [%expect {| - (CVector [(CFloat 8.8); (CFloat 11.4); (CFloat 1.4)]) |}] -;; - -let%expect_test _ = - interp_test - {| -define i4 @main(){ - %a = add i4 8, 0 - %b = add i4 2, 0 - %c = sdiv i4 %a, %b - ret i4 %c -} - |}; - [%expect {| (CInteger (4, 12L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define i4 @main(){ - %a = add i4 9, 0 - %b = add i4 2, 0 - %c = srem i4 %a, %b - ret i4 %c -} - |}; - [%expect {| (CInteger (4, 15L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define i4 @main(){ - %a = add i4 9, 0 - %b = add i4 0, 0 - %c = srem i4 %a, %b - ret i4 %c -} - |}; - [%expect {| Error: Runtime error: Division by 0! |}] -;; - -let%expect_test _ = - interp_test - {| -define float @main(){ - %a = fadd float 0.0, 0.0 - %b = fadd float 2.0, 0.0 - %c = fdiv float %b, %a - ret float %c -} - |}; - [%expect {| (CFloat infinity) |}] -;; - -let%expect_test _ = - interp_test - {| -define <4 x i1> @main(){ - %a = xor <4 x i1> , - ret <4 x i1> %a -} - |}; - [%expect - {| - (CVector - [(CInteger (1, 0L)); (CInteger (1, 1L)); (CInteger (1, 1L)); - (CInteger (1, 0L))]) |}] -;; - -let%expect_test _ = - interp_test - {| -define float @main(){ - %a = extractelement <3 x float> < float 1.2, float -3.4, float 5.6>, i32 1 - ret float %a -} - |}; - [%expect {| - (CFloat -3.4) |}] -;; - -let%expect_test _ = - interp_test - {| -define <3 x float> @main(){ - %a = insertelement <3 x float> < float 1.2, float -3.4, float 5.6>, float 82.0, i32 1 - ret <3 x float> %a -} - |}; - [%expect {| - (CVector [(CFloat 1.2); (CFloat 82.); (CFloat 5.6)]) |}] -;; - -let%expect_test _ = - interp_test - {| -define <2 x float> @main(){ - %a = shufflevector - <3 x float> < float 1.2, float -3.4, float 5.6>, - <3 x float> < float 10.0, float 8.0, float 7.0>, - <2 x i32> - ret <2 x float> %a -} - |}; - [%expect {| - (CVector [(CFloat -3.4); (CFloat 7.)]) |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ - %a = extractvalue {[3 x i32], float} {[3 x i32][i32 21, i32 32, i32 43], float 50.0}, 0, 1 - ret i32 %a -} - |}; - [%expect {| - (CInteger (32, 32L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define {[3 x i32], float} @main(){ - %a = insertvalue {[3 x i32], float} {[3 x i32][i32 21, i32 32, i32 43], float 50.0}, i32 4, 0, 1 - ret {[3 x i32], float} %a -} - |}; - [%expect - {| - (CStruct - [(CArr [(CInteger (32, 21L)); (CInteger (32, 4L)); (CInteger (32, 43L))]); - (CFloat 50.)]) |}] -;; - -let%expect_test _ = - interp_test - {| -define {[3 x i32], float} @main(){ - %a = insertvalue {[3 x i32], float} {[3 x i32][i32 21, i32 32, i32 43], float 50.0}, i32 4, 1 - ret {[3 x i32], float} %a -} - |}; - [%expect - {| - Error: Want to insert value with type (TInteger 32) instead of value with type TFloat! |}] -;; - -let%expect_test _ = - interp_test - {| -define {[3 x i32], float} @main(){ - %a = alloca {[3 x i32], float}, align 4 - store {[3 x i32], float} {[3 x i32][i32 21, i32 32, i32 43], float 50.}, ptr %a, align 4 - %b = load {[3 x i32], float}, ptr %a, align 4 - ret {[3 x i32], float} %b -} - |}; - [%expect - {| - (CStruct - [(CArr [(CInteger (32, 21L)); (CInteger (32, 32L)); (CInteger (32, 43L))]); - (CFloat 50.)]) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 4 - -define i32 @main(){ - %b = load i32, ptr @dd, align 4 - ret i32 %b -} - |}; - [%expect {| - (CInteger (32, 312312L)) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define ptr @main(){ - %b = getelementptr { i32, [3 x i32], i32 }, ptr @dd, i32 1, i32 0, i32 2 - ret ptr %b -} - |}; - [%expect {| - Error: Runtime error: invalid getelementptr indices! |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define ptr @main(){ - %b = getelementptr { i32, [3 x i32], i32 }, ptr @dd, i32 1, i32 1, i32 2 - ret ptr %b -} - |}; - [%expect {| - (CPointer (PointerInt 2032)) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define < 2 x ptr> @main(){ - %b = getelementptr { i32, [3 x i32], i32 }, < 2 x ptr> , - <2 x i32> < i32 2, i32 2> - ret < 2 x ptr> %b -} - |}; - [%expect - {| - (CVector [(CPointer (PointerInt 2040)); (CPointer (PointerInt 2040))]) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define < 2 x ptr> @main(){ - %b = getelementptr { i32, [3 x i32], i32 }, < 2 x ptr> , - <2 x i32> < i32 2, i32 2>, <2 x i32> < i32 2,i32 0> - ret < 2 x ptr> %b -} - |}; - [%expect - {| - (CVector [(CPointer (PointerInt 2056)); (CPointer (PointerInt 2040))]) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define < 2 x ptr> @main(){ - %b = getelementptr { i32, [3 x i32], i32 }, < 2 x ptr> , - <2 x i32> < i32 2, i32 2>, <1 x i32> < i32 2> - ret < 2 x ptr> %b -} - |}; - [%expect {| - Error: Vectors have different size in getlementptr! |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 - -define ptr @main(){ - %a = alloca { [2 x i32], {i32, ptr}, i32 } - store { [2 x i32], {i32, ptr}, i32 }{ [2 x i32][i32 1, i32 2], {i32, ptr}{i32 3, ptr @dd}, i32 4}, ptr %a - %b = getelementptr { [2 x i32], {i32, ptr}, i32 }, ptr %a, i32 0, i32 1, i32 1 - %c = load ptr, ptr %b - ret ptr %c -} - |}; - [%expect {| - (CPointer (PointerInt 2000)) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 -@bb = global i32 23 -@cc = global i32 42 - -define <3 x i32> @main(){ - %a = ptrtoint <3 x ptr> to <3 x i32> - ret <3 x i32> %a -} - |}; - [%expect - {| - (CVector - [(CInteger (32, 2000L)); (CInteger (32, 2004L)); (CInteger (32, 2008L))]) |}] -;; - -let%expect_test _ = - interp_test - {| -@dd = global i32 312312, align 1000 -@bb = global i32 23 -@cc = global i32 42 - -define <3 x i32> @main(){ - %a = ptrtoint <3 x ptr> to <2 x i32> - ret <3 x i32> %a -} - |}; - [%expect {| - Error: Source vector and destination have different size! |}] -;; - -let%expect_test _ = - interp_test - {| -define float @main(){ - %a = sitofp i32 -23 to float - ret float %a -} - |}; - [%expect {| - (CFloat -23.) |}] -;; - -let%expect_test _ = - interp_test - {| -define <3 x i1> @main(){ - %a = icmp eq <3xi32> , - ret <3 x i1> %a -} - |}; - [%expect - {| - (CVector [(CInteger (1, 0L)); (CInteger (1, 1L)); (CInteger (1, 0L))]) |}] -;; - -let%expect_test _ = - interp_test {| -define i1 @main(){ - %a = icmp leq i32 23, 25 - ret i1 %a -} - |}; - [%expect {| - Error: get unknown icmp predicate! |}] -;; - -let%expect_test _ = - interp_test {| -define i1 @main(){ - %a = icmp ule i32 23, 25 - ret i1 %a -} - |}; - [%expect {| - (CInteger (1, 1L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ -one: - br label %two -two: - br label %three -three: - %e = phi i32 [ 0, %one ], [1, %two] - ret i32 %e -} |}; - [%expect {| - (CInteger (32, 1L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ -one: - br label %three -two: - br label %three -three: - %e = phi i32 [ 0, %one ], [1, %two] - ret i32 %e -} |}; - [%expect {| - (CInteger (32, 0L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ -one: - br label %two -two: - br label %three -three: - %e = phi i32 [ 0, %one ] - ret i32 %e -} |}; - [%expect {| - Error: LLVM do crash-crash (clang-17.0.3 )! |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ - %e = select i1 false, i32 17, i32 42 - ret i32 %e -} |}; - [%expect {| - (CInteger (32, 42L)) |}] -;; - -let%expect_test _ = - interp_test - {| -define <2 x i32> @main(){ - %e = select <2 x i1>, <2 x i32> < i32 11, i32 12>, <2 x i32> < i32 21, i32 22> ; yields i8:17 - ret <2 x i32> %e -} |}; - [%expect {| - (CVector [(CInteger (32, 11L)); (CInteger (32, 22L))]) |}] -;; - -let%expect_test _ = - interp_test - {| -define i32 @main(){ - br label %c9 -c9: - %c11 = add i32 0, 1 - br label %c14 -c12: - %c12 = add i32 0, 4 - br label %c14 -c14: - %c15 = phi i32 [ %c11, %c9 ], [ %c13, %c12 ] - ret i32 %c15 - -} |}; - [%expect {| - (CInteger (32, 1L)) |}] -;; diff --git a/LLVM_IR/lib/interpreter/interpreting.mli b/LLVM_IR/lib/interpreter/interpreting.mli deleted file mode 100644 index f0915e843..000000000 --- a/LLVM_IR/lib/interpreter/interpreting.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val run_interpretate_on_ast - : Ast.glob_list - -> Ihelp.State.state * (Ast.const, string) result diff --git a/LLVM_IR/lib/interpreter/memory.ml b/LLVM_IR/lib/interpreter/memory.ml deleted file mode 100644 index 75998dcc1..000000000 --- a/LLVM_IR/lib/interpreter/memory.ml +++ /dev/null @@ -1,57 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open State - -let align_addr addr align isUp = - let res = addr / align * align in - if res <> addr then if isUp then res + align else res else res -;; - -let put_bytes_in_heap : int -> char list -> (state, unit) t = - fun addr lst -> - let indxs = List.init (List.length lst) (fun x -> addr + x) in - let bts = List.to_seq (List.combine indxs lst) in - write_bytes bts -;; - -let put_cnst_in_heap : int -> Ast.const -> (state, unit) t = - fun addr cnst -> - let* cnst = - match cnst with - | Ast.CPointer (Ast.PointerGlob x) -> read_var x - | cns -> return cns - in - let* lst = Serialisation.serialise_with_state cnst in - put_bytes_in_heap addr lst -;; - -(* let put_cnst_in_heap_align : int -> Ast.const -> int -> (state, unit) t = - fun addr cnst align -> put_cnst_in_heap (align_addr addr align true) cnst - ;; *) - -let take_cnst_from_heap : int -> Ast.tp -> (state, Ast.const) t = - fun addr tp -> - let indxs = List.init (Serialisation.raw_date_len tp) (fun x -> addr + x) in - let* bts = map_list read_byte indxs in - return (Serialisation.deserialise tp bts) -;; - -let alloc_stack_align : int -> int -> (state, int) t = - fun len align -> - let* old_local, old_global, old_heap, old_stack, old_block = read in - let addr = align_addr (old_stack - len) align false in - write (old_local, old_global, old_heap, addr, old_block) *> return addr -;; - -let free_stack : int -> (state, unit) t = - fun new_stack -> - let* old_local, old_global, old_heap, old_stack, old_block = read in - let new_heap = - MapInt.filter - (fun cur_addr _ -> not (cur_addr < new_stack && cur_addr >= old_stack)) - old_heap - in - write (old_local, old_global, new_heap, new_stack, old_block) -;; diff --git a/LLVM_IR/lib/interpreter/memory.mli b/LLVM_IR/lib/interpreter/memory.mli deleted file mode 100644 index 53a3318fd..000000000 --- a/LLVM_IR/lib/interpreter/memory.mli +++ /dev/null @@ -1,13 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val align_addr : int -> int -> bool -> int -val put_bytes_in_heap : int -> char list -> (State.state, unit) State.t -val put_cnst_in_heap : int -> Ast.const -> (State.state, unit) State.t - -(* val put_cnst_in_heap_align : - int -> Ast.const -> int -> (State.state, unit) State.t *) -val take_cnst_from_heap : int -> Ast.tp -> (State.state, Ast.const) State.t -val alloc_stack_align : int -> int -> (State.state, int) State.t -val free_stack : int -> (State.state, unit) State.t diff --git a/LLVM_IR/lib/interpreter/serialisation.ml b/LLVM_IR/lib/interpreter/serialisation.ml deleted file mode 100644 index ded08f1d1..000000000 --- a/LLVM_IR/lib/interpreter/serialisation.ml +++ /dev/null @@ -1,187 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open State - -let div_up x y = - let res = x / y in - if y * res <> x then res + 1 else res -;; - -let get_n_byte x n = - Char.chr - (Int64.to_int - (Int64.shift_right_logical - (Int64.logand x (Int64.shift_left 0xffL (8 * n))) - (8 * n))) -;; - -let rec raw_date_len : Ast.tp -> int = function - | Ast.TVoid -> 0 - | Ast.TFloat -> 8 - | Ast.TInteger x -> div_up x 8 - | Ast.TPointer -> 8 - | Ast.TArr (n, tp) | Ast.TVector (n, tp) -> raw_date_len tp * n - | Ast.TStruct tps -> List.fold_left (fun acc tp -> acc + raw_date_len tp) 0 tps - | Ast.TLabel | Ast.TFunc (_, _) -> - let _ = Printf.printf "Imposible error: func and label can't be serealized" in - 0 -;; - -let serialise_int sz value = - let len = div_up sz 8 in - List.init len (get_n_byte value) -;; - -let serialise_flt flt = - let iflt = Int64.bits_of_float flt in - serialise_int 64 iflt -;; - -let rec serialise_aggregate_tp cnsts = - let f cnst = - let* lst2 = serialise_with_state cnst in - return lst2 - in - let* lsts = map_list f cnsts in - return (List.concat lsts) - -and serialise_with_state : Ast.const -> (state, char list) t = function - | Ast.CVoid -> return [] - | Ast.CInteger (sz, value) -> return (serialise_int sz value) - | Ast.CFloat flt -> return (serialise_flt flt) - | Ast.CPointer (Ast.PointerInt integer) -> - return (serialise_int 63 (Int64.of_int integer)) - | Ast.CVector cnst | Ast.CArr cnst | Ast.CStruct cnst -> serialise_aggregate_tp cnst - | Ast.CLabel _ | Ast.CFunc _ -> - fail "Imposible error: func and label can't be serealized" - | Ast.CPointer (Ast.PointerGlob x) -> read_var x >>= serialise_with_state -;; - -let bytes_to_int lst = - let f el acc = Int64.add (Int64.mul acc 0x100L) (Int64.of_int (Char.code el)) in - List.fold_right f lst 0L -;; - -let deserialise_int sz lst = Common.IrInts.create (bytes_to_int lst) sz - -let deserialise_flt lst = - let iflt = bytes_to_int lst in - Ast.CFloat (Int64.float_of_bits iflt) -;; - -let deserialise_ptr lst = - let iflt = Int64.to_int (bytes_to_int lst) in - Ast.CPointer (Ast.PointerInt iflt) -;; - -let rec bytes_to_cnst_lst : char list -> Ast.tp list -> Ast.const list = - let split_list ind mslt = - let rec help x lst1 lst2 = - if x < ind - then ( - match lst2 with - | h :: tl -> help (x + 1) (h :: lst1) tl - | _ -> help (x + 1) lst1 lst2) - else lst1, lst2 - in - let lst1, lst2 = help 0 [] mslt in - List.rev lst1, lst2 - in - fun data tps -> - let f (raw_data, acc_lst) tp = - let len = raw_date_len tp in - let lst1, lst2 = split_list len raw_data in - lst2, deserialise tp lst1 :: acc_lst - in - let _, res = List.fold_left f (data, []) tps in - List.rev res - -and deserialise_vec n tp lst = - let tps = List.init n (fun _ -> tp) in - Ast.CVector (bytes_to_cnst_lst lst tps) - -and deserialise_arr n tp lst = - let tps = List.init n (fun _ -> tp) in - Ast.CArr (bytes_to_cnst_lst lst tps) - -and deserialise_struct tps lst = Ast.CStruct (bytes_to_cnst_lst lst tps) - -and deserialise : Ast.tp -> char list -> Ast.const = - fun tp lst -> - match tp with - | Ast.TVoid -> Ast.CVoid - | Ast.TInteger sz -> deserialise_int sz lst - | Ast.TFloat -> deserialise_flt lst - | Ast.TPointer -> deserialise_ptr lst - | Ast.TVector (n, tp) -> deserialise_vec n tp lst - | Ast.TArr (n, tp) -> deserialise_arr n tp lst - | Ast.TStruct tps -> deserialise_struct tps lst - | Ast.TLabel | Ast.TFunc (_, _) -> - let _ = Printf.printf "Imposible error: func and label can't be serealized" in - Ast.CVoid -;; - -let ser_deser target = - let res = run (serialise_with_state target) empty_state in - match res with - | _, Result.Ok bts -> deserialise (Ast.const_to_tp target) bts - | _, Result.Error _ -> CVoid -;; - -let ser_test target print = - let t1 = Ast.show_const (ser_deser target) in - let t2 = Ast.show_const target in - let _ = - if print - then - Printf.printf - {| ######################## - Exp: %s - ---------------- - Get: %s - ######################## - - |} - t2 - t1 - in - String.equal t1 t2 -;; - -let%test _ = ser_test Ast.CVoid false -let%test _ = ser_test (Common.IrInts.create 0x23232323L 32) false -let%test _ = ser_test (Common.IrInts.create 0x111111111L 32) false -let%test _ = ser_test (Common.IrInts.create (-1L) 32) false -let%test _ = ser_test (Common.IrInts.create (-1L) 7) false -let%test _ = ser_test (Common.IrInts.create (-45L) 11) false -let%test _ = ser_test (CFloat 1.00) false -let%test _ = ser_test (CFloat (-21.00)) false -let%test _ = ser_test (CFloat 30.0002) false -let%test _ = ser_test (CFloat 30.000000000000002) false -let%test _ = ser_test (CFloat 123.45678901234567) false -let%test _ = ser_test (CPointer (PointerInt 0x11)) false -let%test _ = ser_test (CPointer (PointerInt 0x40000)) false - -let ser_parse_test str print = - match Parser.CommonParser.test_parse_res Parser.Values.parse_type_with_value str with - | Result.Ok (_, Ast.Const cnst) -> ser_test cnst print - | _ -> - let _ = if print then Printf.printf "Error during parse '%s'\n" str in - false -;; - -let%test _ = - ser_parse_test - "<8 x i32> " - false -;; - -let%test _ = - ser_parse_test - "[2 x [2 x i32]] [[2 x i32] [i32 1, i32 3], [2 x i32] [i32 2, i32 4]] " - false -;; - -let%test _ = ser_parse_test "{i32, float} { i32 4, float 17.0} " false diff --git a/LLVM_IR/lib/interpreter/serialisation.mli b/LLVM_IR/lib/interpreter/serialisation.mli deleted file mode 100644 index c2f721d3b..000000000 --- a/LLVM_IR/lib/interpreter/serialisation.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val raw_date_len : Ast.tp -> int -val serialise_with_state : Ast.const -> (State.state, char list) State.t -val deserialise : Ast.tp -> char list -> Ast.const diff --git a/LLVM_IR/lib/interpreter/state.ml b/LLVM_IR/lib/interpreter/state.ml deleted file mode 100644 index 4336b7c6c..000000000 --- a/LLVM_IR/lib/interpreter/state.ml +++ /dev/null @@ -1,104 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -include Common.StateMonad - -module MapString = struct - include Map.Make (String) - - let pp pp_v ppf m = - Format.fprintf ppf "@[[@["; - iter (fun k v -> Format.fprintf ppf "@[\"%S\": %a@],@\n" k pp_v v) m; - Format.fprintf ppf "@]]@]" - ;; -end - -module MapInt = struct - include Map.Make (Int) - - let pp pp_v ppf m = - Format.fprintf ppf "@[[@["; - iter (fun k v -> Format.fprintf ppf "@[\"%x\": %a@],@\n" k pp_v v) m; - Format.fprintf ppf "@]]@]" - ;; -end - -type map_heap = char MapInt.t [@@deriving show { with_path = false }] -type map_var = Ast.const MapString.t [@@deriving show { with_path = false }] -type bytes = (int * char) Seq.t - -type state = map_var * map_var * map_heap * int * Ast.variable -(*local glob heap stack_pointer*) [@@deriving show { with_path = false }] - -let glob_sect = 1024 -let stack_sect = 0xcf000000 -let last_block_init = Ast.LocalVar "" - -let empty_state : state = - MapString.empty, MapString.empty, MapInt.empty, stack_sect, last_block_init -;; - -let read_var : Ast.variable -> (state, Ast.const) t = - let find_var name map = - let value = MapString.find_opt name map in - match value with - | Some x -> return x - | None -> fail (Printf.sprintf "Runtime error: Variable %s is not initialized" name) - in - fun variable -> - let* local, glob, _, _, _ = read in - match variable with - | Ast.GlobalVar name -> find_var name glob - | Ast.LocalVar name -> find_var name local -;; - -let write_var : Ast.variable -> Ast.const -> (state, unit) t = - fun key value -> - let* old_local, old_global, old_heap, old_stack, old_block = read in - match key with - | Ast.GlobalVar name -> - write (old_local, MapString.add name value old_global, old_heap, old_stack, old_block) - | Ast.LocalVar name -> - write (MapString.add name value old_local, old_global, old_heap, old_stack, old_block) -;; - -let read_byte : int -> (state, char) t = - fun number -> - let* _, _, heap, _, _ = read in - let bt = MapInt.find_opt number heap in - match bt with - | Some x -> return x - | None -> - fail (Printf.sprintf "Runtime error: Byte number %x is not initialized" number) -;; - -let read_bytes : int -> int -> (state, char list) t = - fun first len -> - let read_right_byte num = read_byte (first + num) in - let buf_list = List.init len (fun x -> x) in - map_list read_right_byte buf_list -;; - -let write_bytes : bytes -> (state, unit) t = - fun bts -> - let* old_local, old_global, old_heap, old_stack, old_block = read in - write (old_local, old_global, MapInt.add_seq bts old_heap, old_stack, old_block) -;; - -let read_last_block : (state, Ast.variable) t = - let* _, _, _, _, block = read in - return block -;; - -let write_last_block : Ast.variable -> (state, unit) t = - fun block -> - let* old_local, old_global, old_heap, old_stack, _ = read in - write (old_local, old_global, old_heap, old_stack, block) -;; - -let print_loc_vars : (state, unit) t = - let* old_local, old_global, old_heap, old_stack, block = read in - let _ = Printf.printf "%s\n\n\n" (show_map_var old_local) in - return () -;; diff --git a/LLVM_IR/lib/interpreter/state.mli b/LLVM_IR/lib/interpreter/state.mli deleted file mode 100644 index 683af198d..000000000 --- a/LLVM_IR/lib/interpreter/state.mli +++ /dev/null @@ -1,138 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -type ('st, 'a) t = 'st -> 'st * ('a, string) result - -val return : 'a -> 'b -> 'b * ('a, 'c) result -val fail : 'a -> 'b -> 'b * ('c, 'a) result -val ( >>= ) : ('s, 'a) t -> ('a -> ('s, 'b) t) -> ('s, 'b) t -val read : ('st, 'st) t -val write : 'st -> ('st, unit) t -val run : ('st, 'a) t -> 'st -> 'st * ('a, string) result -val ( let* ) : ('a, 'b) t -> ('b -> ('a, 'c) t) -> ('a, 'c) t -val ( *> ) : ('a, 'b) t -> ('a, 'c) t -> ('a, 'c) t -val ( >>| ) : ('a, 'b) t -> ('b -> 'c) -> ('a, 'c) t -val ( <* ) : ('a, 'b) t -> ('a, 'c) t -> ('a, 'b) t -val map_list : ('a -> ('st, 'b) t) -> 'a list -> ('st, 'b list) t - -module MapString : sig - type key = string - type 'a t = 'a Map.Make(String).t - - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t - val pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit -end - -module MapInt : sig - type key = int - type 'a t = 'a Map.Make(Int).t - - val empty : 'a t - val is_empty : 'a t -> bool - val mem : key -> 'a t -> bool - val add : key -> 'a -> 'a t -> 'a t - val update : key -> ('a option -> 'a option) -> 'a t -> 'a t - val singleton : key -> 'a -> 'a t - val remove : key -> 'a t -> 'a t - val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t - val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t - val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int - val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool - val iter : (key -> 'a -> unit) -> 'a t -> unit - val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val for_all : (key -> 'a -> bool) -> 'a t -> bool - val exists : (key -> 'a -> bool) -> 'a t -> bool - val filter : (key -> 'a -> bool) -> 'a t -> 'a t - val filter_map : (key -> 'a -> 'b option) -> 'a t -> 'b t - val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t - val cardinal : 'a t -> int - val bindings : 'a t -> (key * 'a) list - val min_binding : 'a t -> key * 'a - val min_binding_opt : 'a t -> (key * 'a) option - val max_binding : 'a t -> key * 'a - val max_binding_opt : 'a t -> (key * 'a) option - val choose : 'a t -> key * 'a - val choose_opt : 'a t -> (key * 'a) option - val split : key -> 'a t -> 'a t * 'a option * 'a t - val find : key -> 'a t -> 'a - val find_opt : key -> 'a t -> 'a option - val find_first : (key -> bool) -> 'a t -> key * 'a - val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option - val find_last : (key -> bool) -> 'a t -> key * 'a - val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option - val map : ('a -> 'b) -> 'a t -> 'b t - val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t - val to_seq : 'a t -> (key * 'a) Seq.t - val to_rev_seq : 'a t -> (key * 'a) Seq.t - val to_seq_from : key -> 'a t -> (key * 'a) Seq.t - val add_seq : (key * 'a) Seq.t -> 'a t -> 'a t - val of_seq : (key * 'a) Seq.t -> 'a t - val pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit -end - -type map_heap = char MapInt.t - -val pp_map_heap : Format.formatter -> map_heap -> unit -val show_map_heap : map_heap -> string - -type map_var = Ast.const MapString.t - -val pp_map_var : Format.formatter -> map_var -> unit -val show_map_var : map_var -> string - -type bytes = (int * char) Seq.t -type state = map_var * map_var * map_heap * int * Ast.variable - -val pp_state : Format.formatter -> state -> unit -val show_state : state -> string -val glob_sect : int -val stack_sect : int -val last_block_init : Ast.variable -val empty_state : state -val read_var : Ast.variable -> (state, Ast.const) t -val write_var : Ast.variable -> Ast.const -> (state, unit) t -val read_byte : int -> (state, char) t -val read_bytes : int -> int -> (state, char list) t -val write_bytes : bytes -> (state, unit) t -val read_last_block : (state, Ast.variable) t -val write_last_block : Ast.variable -> (state, unit) t diff --git a/LLVM_IR/lib/main.ml b/LLVM_IR/lib/main.ml deleted file mode 100644 index 6827a2749..000000000 --- a/LLVM_IR/lib/main.ml +++ /dev/null @@ -1,24 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ihelp - -let interpretate_programm prog = - let p_res = Parser.Parsing.parse_program prog in - match p_res with - | Result.Ok ast -> - let c_res = Checks.SsaCheck.run_ssa_glob_list ast in - (match c_res with - | Result.Ok _ -> - let i_res = Interpreter.Interpreting.run_interpretate_on_ast ast in - (match i_res with - | _, Result.Ok res -> - Printf.printf "Programm return: \n\t %s" (Ast.show_const res) - | st, Result.Error s -> - let _ = Printf.printf "Got error during interpretation \n\t%s" s in - let _ = Printf.printf "\n\n%s" (State.show_state st) in - ()) - | Result.Error s -> Printf.printf "SSA check failed: \n\t%s" s) - | Result.Error s -> Printf.printf "Parser error: \n\t%s" s -;; diff --git a/LLVM_IR/lib/main.mli b/LLVM_IR/lib/main.mli deleted file mode 100644 index df38353ea..000000000 --- a/LLVM_IR/lib/main.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val interpretate_programm : string -> unit diff --git a/LLVM_IR/lib/parser/commonParser.ml b/LLVM_IR/lib/parser/commonParser.ml deleted file mode 100644 index c6e7c3102..000000000 --- a/LLVM_IR/lib/parser/commonParser.ml +++ /dev/null @@ -1,117 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Angstrom - -let test_parse_res p str = Angstrom.parse_string ~consume:Consume.Prefix p str - -let test_parse p show str = - match test_parse_res p str with - | Result.Error _ -> Format.printf "Error" - | Result.Ok ast -> Format.printf "%s" (show ast) -;; - -let whitespace = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let comment = - char ';' - *> return () - *> skip_while (function - | '\n' -> false - | _ -> true) -;; - -let whitespaces = many (skip whitespace <|> comment) -let comma = whitespaces *> char ',' <* whitespaces - -let str_integer = - take_while1 (function - | '0' .. '9' -> true - | _ -> false) -;; - -let str_extended_integer = - take_while1 (function - | 'a' .. 'f' -> true - | 'A' .. 'F' -> true - | '0' .. '9' -> true - | _ -> false) -;; - -let varname_char = function - | 'a' .. 'z' -> true - | 'A' .. 'Z' -> true - | '.' | '$' | '_' | '-' | '+' -> true - | _ -> false -;; - -let parse_word = - let satisfy_char = function - | a when varname_char a -> true - | '0' .. '9' -> true - | _ -> false - in - take_while1 satisfy_char -;; - -let word str = - parse_word - >>= fun parsed -> if parsed = str then return str else fail "Parser error: Wrong word" -;; - -let parse_integer64 = - let* prefix = choice [ string "0x"; string "0o"; string "0b"; return "" ] in - let* int_body = str_extended_integer in - match Int64.of_string_opt (String.concat "" [ prefix; int_body ]) with - | Some x -> return x - | None -> fail "Parser error: can't parse int" -;; - -let parse_integer = parse_integer64 >>| Int64.to_int - -let parse_named_name = - lift2 - (fun first_char last_part -> String.make 1 first_char ^ last_part) - (satisfy varname_char) - (parse_word <|> return "") -;; - -let parse_unnamed_name = - lift2 - (fun name _ -> name) - str_integer - (peek_char - >>= fun c -> - match c with - | Some c when varname_char c -> fail "Parser error: deprecated name" - | _ -> return ()) -;; - -let%expect_test _ = - test_parse parse_unnamed_name (fun f -> f) "543554"; - [%expect {| 543554 |}] -;; - -let%expect_test _ = - test_parse parse_unnamed_name (fun f -> f) "543554d"; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse parse_unnamed_name (fun f -> f) "54,"; - [%expect {| 54 |}] -;; - -let parse_name = parse_named_name <|> parse_unnamed_name - -let parse_local_variable = - whitespaces *> char '%' *> parse_name >>| fun name -> Ast.LocalVar name -;; - -let parse_global_variable = - whitespaces *> char '@' *> parse_name >>| fun name -> Ast.GlobalVar name -;; diff --git a/LLVM_IR/lib/parser/commonParser.mli b/LLVM_IR/lib/parser/commonParser.mli deleted file mode 100644 index 439510b9a..000000000 --- a/LLVM_IR/lib/parser/commonParser.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val test_parse_res : 'a Angstrom.t -> string -> ('a, string) result -val test_parse : 'a Angstrom.t -> ('a -> string) -> string -> unit -val whitespaces : unit list Angstrom.t -val comma : char Angstrom.t -val parse_integer : int Angstrom.t -val parse_integer64 : Int64.t Angstrom.t -val parse_word : string Angstrom.t -val word : string -> string Angstrom.t -val parse_name : string Angstrom.t -val parse_local_variable : Ast.variable Angstrom.t -val parse_global_variable : Ast.variable Angstrom.t diff --git a/LLVM_IR/lib/parser/dune b/LLVM_IR/lib/parser/dune deleted file mode 100644 index 9be63f468..000000000 --- a/LLVM_IR/lib/parser/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name parser) - (public_name LLVM_IR.Parser) - (modules commonParser parsing types values instructions) - (libraries ast common base angstrom ppx_show.runtime) - (inline_tests) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/LLVM_IR/lib/parser/instructions.ml b/LLVM_IR/lib/parser/instructions.ml deleted file mode 100644 index ad984f2e4..000000000 --- a/LLVM_IR/lib/parser/instructions.ml +++ /dev/null @@ -1,699 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Angstrom -open CommonParser -open Values -open Types - -let parse_instruction_result = parse_local_variable <* whitespaces <* char '=' -let parse_align = comma *> word "align" *> whitespaces *> parse_integer <|> return 1 - -let parse_terminator_instruction = - let iret = - word "ret" *> whitespaces *> parse_type_with_value - >>| function - | tp, value -> Ast.Ret (tp, value) - and ibr = - word "br" *> whitespaces *> type_with_value Ast.TLabel >>| fun value -> Ast.Br value - and ibr_cond = - word "br" - *> lift3 - (fun b l1 l2 -> Ast.BrCond (b, l1, l2)) - (type_with_value (Ast.TInteger 1) <* comma) - (type_with_value Ast.TLabel <* comma) - (type_with_value Ast.TLabel) - and iswitch = - word "switch" - *> let* value_type, switch_value = parse_type_with_value <* comma in - let* default_dest = type_with_value Ast.TLabel in - let* switch_list = - whitespaces - *> char '[' - *> whitespaces - *> many - (lift2 - (fun x y -> x, y) - (type_with_value value_type <* comma) - (type_with_value Ast.TLabel)) - <* whitespaces - <* char ']' - in - return (Ast.Switch (value_type, switch_value, default_dest, switch_list)) - and iunreachable = word "unreachable" *> return Ast.Unreachable in - whitespaces *> choice [ iret; ibr; ibr_cond; iswitch; iunreachable ] -;; - -let parse_unary_operation = - let ifneg = - let* res_var = parse_instruction_result in - let* tp, value = whitespaces *> word "fneg" *> whitespaces *> parse_type_with_value in - return (Ast.Fneg (res_var, tp, value)) - in - whitespaces *> choice [ ifneg ] -;; - -let parse_binary_operation = - let help (mnem : string) (bin_op : Ast.binary_operation_body -> Ast.binary_operation) = - parse_instruction_result - >>= fun var -> - whitespaces - *> word mnem - *> whitespaces - *> option [] (word "nuw" *> whitespaces) - *> option [] (word "nsw" *> whitespaces) - *> whitespaces - *> parse_type_with_value2 - >>= function - | tp, v1, v2 -> return (bin_op (var, tp, v1, v2)) - in - whitespaces - *> choice - [ help "add" (fun x -> Ast.Add x) - ; help "fadd" (fun x -> Ast.Fadd x) - ; help "mul" (fun x -> Ast.Mul x) - ; help "fmul" (fun x -> Ast.Fmul x) - ; help "sub" (fun x -> Ast.Sub x) - ; help "fsub" (fun x -> Ast.Fsub x) - ; help "udiv" (fun x -> Ast.Udiv x) - ; help "sdiv" (fun x -> Ast.Sdiv x) - ; help "fdiv" (fun x -> Ast.Fdiv x) - ; help "urem" (fun x -> Ast.Urem x) - ; help "srem" (fun x -> Ast.Srem x) - ; help "frem" (fun x -> Ast.Frem x) - ] -;; - -let parse_bitwise_binary_operation = - let help - (mnem : string) - (bin_op : Ast.binary_operation_body -> Ast.bitwise_binary_operation) - = - parse_instruction_result - >>= fun var -> - whitespaces *> word mnem *> whitespaces *> parse_type_with_value2 - >>= function - | tp, v1, v2 -> return (bin_op (var, tp, v1, v2)) - in - whitespaces - *> choice - [ help "shl" (fun x -> Ast.Shl x) - ; help "lshr" (fun x -> Ast.Lshr x) - ; help "ashr" (fun x -> Ast.Ashr x) - ; help "and" (fun x -> Ast.And x) - ; help "or" (fun x -> Ast.Or x) - ; help "xor" (fun x -> Ast.Xor x) - ] -;; - -let parse_vector_instruction = - let iextractelement = - let* res_var = parse_instruction_result in - let* vec_tp, vec_val = - whitespaces *> word "extractelement" *> whitespaces *> parse_type_with_value - <* comma - in - let* int_tp, int_val = parse_type_with_value in - return (Ast.Extractelement (res_var, vec_tp, vec_val, int_tp, int_val)) - and iinsertelement = - let* res_var = parse_instruction_result in - let* vec_tp, vec_val = - whitespaces *> word "insertelement" *> whitespaces *> parse_type_with_value <* comma - in - let* elem_val = - match vec_tp with - | Ast.TVector (_, elem_tp) -> type_with_value elem_tp <* comma - | _ -> fail "Parser error: insertelement's first value should be vector type" - in - let* int_tp, int_val = parse_type_with_value in - return (Ast.Insertelement (res_var, vec_tp, vec_val, elem_val, int_tp, int_val)) - and ishufflevector = - let* res_var = parse_instruction_result in - let* vec_tp, vec_v1 = - whitespaces *> word "shufflevector" *> whitespaces *> parse_type_with_value <* comma - in - let* vec_v2 = type_with_value vec_tp <* comma in - let* mask_tp, mask_val = parse_type_with_value in - match mask_tp, mask_val with - | Ast.TVector (mask_size, Ast.TInteger 32), Ast.Const mask_const -> - return (Ast.Shufflevector (res_var, vec_tp, vec_v1, vec_v2, mask_size, mask_const)) - | _ -> fail "Parser error: couldn't parse mask for shufflevector instruction" - in - whitespaces *> choice [ iextractelement; iinsertelement; ishufflevector ] -;; - -let parse_aggregate_instruction = - let iextractvalue = - let* res_var = parse_instruction_result in - let* agg_tp, agg_val = - whitespaces *> word "extractvalue" *> whitespaces *> parse_type_with_value <* comma - in - let* indexes = sep_by1 comma parse_integer in - return (Ast.Extractvalue (res_var, agg_tp, agg_val, indexes)) - and iinsertvalue = - let* res_var = parse_instruction_result in - let* agg_tp, agg_val = - whitespaces *> word "insertvalue" *> whitespaces *> parse_type_with_value <* comma - in - let* value_tp, value_val = parse_type_with_value <* comma in - let* indexes = sep_by1 comma parse_integer in - return (Ast.Insertvalue (res_var, agg_tp, agg_val, value_tp, value_val, indexes)) - in - whitespaces *> choice [ iextractvalue; iinsertvalue ] -;; - -let parse_memory_instruction = - let ialloca = - lift4 - (fun var tp value align -> Ast.Alloca (var, tp, value, align)) - parse_instruction_result - (whitespaces *> word "alloca" *> parse_main_type) - (comma *> parse_type_with_value - >>= (function - | Ast.TInteger _, value -> return value - | _ -> fail "Parser error: excepted integer type") - <|> return (Ast.Const (Ast.CInteger (1, 1L)))) - (whitespaces *> parse_align) - and istore = - lift3 - (fun (tp, value) vptr align -> Ast.Store (tp, value, vptr, align)) - (whitespaces *> word "store" *> whitespaces *> parse_type_with_value) - (comma *> type_with_value Ast.TPointer) - parse_align - and iload = - lift4 - (fun res tp vptr align -> Ast.Load (res, tp, vptr, align)) - parse_instruction_result - (whitespaces *> word "load" *> parse_main_type) - (comma *> type_with_value Ast.TPointer) - parse_align - and igetelementptr = - let* res_var = parse_instruction_result in - let* res_tp = whitespaces *> word "getelementptr" *> parse_additional_type <* comma in - let* ptr_tp, ptr_val = parse_type_with_value in - let* index_lst = choice [ comma *> sep_by1 comma parse_type_with_value; return [] ] in - return (Ast.Getelementptr (res_var, res_tp, ptr_tp, ptr_val, index_lst)) - in - whitespaces *> choice [ ialloca; istore; iload; igetelementptr ] -;; - -let parse_conversion_instruction = - let help - (mnem : string) - (conv_inst : Ast.conversion_instruction_body -> Ast.conversion_instruction) - = - let* res_var = parse_instruction_result in - let* value_tp_src, value_val = - whitespaces *> word mnem *> whitespaces *> parse_type_with_value - in - let* value_tp_dst = - whitespaces *> word "to" *> whitespaces *> parse_additional_type - in - return (conv_inst (res_var, value_tp_src, value_val, value_tp_dst)) - in - whitespaces - *> choice - [ help "trunc" (fun x -> Ast.TruncTo x) - ; help "zext" (fun x -> Ast.ZextTo x) - ; help "sext" (fun x -> Ast.SextTo x) - ; help "fptoui" (fun x -> Ast.FptouiTo x) - ; help "fptosi" (fun x -> Ast.FptosiTo x) - ; help "uitofp" (fun x -> Ast.UitofpTo x) - ; help "sitofp" (fun x -> Ast.SitofpTo x) - ; help "ptrtoint" (fun x -> Ast.PrttointTo x) - ; help "inttoptr" (fun x -> Ast.InttoprtTo x) - ] -;; - -let parse_other_operation = - let iicmp = - lift3 - (fun var cond (tp, v1, v2) -> Ast.Icmp (var, cond, tp, v1, v2)) - parse_instruction_result - (whitespaces *> word "icmp" *> whitespaces *> parse_word) - (whitespaces *> parse_type_with_value2) - and ifcmp = - lift3 - (fun var cond (tp, v1, v2) -> Ast.Fcmp (var, cond, tp, v1, v2)) - parse_instruction_result - (whitespaces *> word "fcmp" *> whitespaces *> parse_word) - (whitespaces *> parse_type_with_value2) - and iphi = - let* res_var = parse_instruction_result in - let* res_tp = whitespaces *> word "phi" *> whitespaces *> parse_additional_type in - let* choose_lst = - sep_by1 - comma - (whitespaces *> char '[' *> parse_value res_tp - >>= (fun value -> - comma *> parse_value Ast.TLabel >>= fun label -> return (value, label)) - <* whitespaces - <* char ']') - in - return (Ast.Phi (res_var, res_tp, choose_lst)) - and iselect = - let* res_var = parse_instruction_result in - let* cond_tp, cond_val = - whitespaces *> word "select" *> whitespaces *> parse_type_with_value <* comma - in - let* value_tp, value_v1 = parse_type_with_value <* comma in - let* value_v2 = type_with_value value_tp in - return (Ast.Select (res_var, cond_tp, cond_val, value_tp, value_v1, value_v2)) - and icall = - lift4 - (fun var ret_tp vptr arg_lst -> Ast.Call (var, ret_tp, vptr, arg_lst)) - parse_instruction_result - (whitespaces *> word "call" *> whitespaces *> parse_additional_type) - (whitespaces *> parse_value Ast.TPointer) - (whitespaces - *> char '(' - *> sep_by - comma - (whitespaces *> parse_type_with_value - >>= function - | _, value -> return value) - <* whitespaces - <* char ')') - in - whitespaces *> choice [ iicmp; ifcmp; iphi; iselect; icall ] -;; - -let parse_instruction : Ast.instruction t = - choice - [ (parse_terminator_instruction >>| fun ins -> Ast.Terminator ins) - ; (parse_unary_operation >>| fun ins -> Ast.Unary ins) - ; (parse_binary_operation >>| fun ins -> Ast.Binary ins) - ; (parse_bitwise_binary_operation >>| fun ins -> Ast.BitwiseBinary ins) - ; (parse_vector_instruction >>| fun ins -> Ast.Vector ins) - ; (parse_aggregate_instruction >>| fun ins -> Ast.Aggregate ins) - ; (parse_other_operation >>| fun ins -> Ast.Other ins) - ; (parse_memory_instruction >>| fun ins -> Ast.MemoryAddress ins) - ; (parse_conversion_instruction >>| fun ins -> Ast.Conversion ins) - ] -;; - -(* ##########################################################*) -(* ################ TERMINATOR ##############################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction "ret i32 %14"; - [%expect - {| - (Terminator - (Ret ((TInteger 32), (FromVariable ((LocalVar "14"), (TInteger 32)))))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction "br label %13"; - [%expect {| - (Terminator (Br (FromVariable ((LocalVar "13"), TLabel)))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " br i1 %5, label %6, label %7"; - [%expect - {| - (Terminator - (BrCond ((FromVariable ((LocalVar "5"), (TInteger 1))), - (FromVariable ((LocalVar "6"), TLabel)), - (FromVariable ((LocalVar "7"), TLabel))))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - {| switch i32 %val, label %otherwise [ i32 0, label %onzero - i32 1, label %onone - i32 2, label %ontwo ] |}; - [%expect - {| - (Terminator - (Switch ((TInteger 32), (FromVariable ((LocalVar "val"), (TInteger 32))), - (FromVariable ((LocalVar "otherwise"), TLabel)), - [((Const (CInteger (32, 0L))), - (FromVariable ((LocalVar "onzero"), TLabel))); - ((Const (CInteger (32, 1L))), - (FromVariable ((LocalVar "onone"), TLabel))); - ((Const (CInteger (32, 2L))), - (FromVariable ((LocalVar "ontwo"), TLabel))) - ] - ))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction {| unreachable |}; - [%expect {| - (Terminator Unreachable) |}] -;; - -(* ##########################################################*) -(* ##################### UNARY ##############################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction {| %23 = fneg float %val |}; - [%expect - {| - (Unary - (Fneg ((LocalVar "23"), TFloat, (FromVariable ((LocalVar "val"), TFloat)) - ))) |}] -;; - -(* ##########################################################*) -(* #################### BINARY ##############################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %9 = sub i32 %8, 1"; - [%expect - {| - (Binary - (Sub - ((LocalVar "9"), (TInteger 32), - (FromVariable ((LocalVar "8"), (TInteger 32))), - (Const (CInteger (32, 1L)))))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %12 = mul i32 %10, %11"; - [%expect - {| - (Binary - (Mul - ((LocalVar "12"), (TInteger 32), - (FromVariable ((LocalVar "10"), (TInteger 32))), - (FromVariable ((LocalVar "11"), (TInteger 32)))))) |}] -;; - -(* ##########################################################*) -(* #################### BITWISE #############################*) -(* ########################################################## *) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %res = xor i32 0x1A, %var "; - [%expect - {| - (BitwiseBinary - (Xor - ((LocalVar "res"), (TInteger 32), (Const (CInteger (32, 26L))), - (FromVariable ((LocalVar "var"), (TInteger 32)))))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %res = ashr i8 -4, -0x23 "; - [%expect - {| - (BitwiseBinary - (Ashr - ((LocalVar "res"), (TInteger 8), (Const (CInteger (8, 252L))), - (Const (CInteger (8, 221L)))))) |}] -;; - -(* ##########################################################*) -(* ##################### VECTOR #############################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%result = extractelement <4 x i32> %vec, i32 0 "; - [%expect - {| - (Vector - (Extractelement ((LocalVar "result"), (TVector (4, (TInteger 32))), - (FromVariable ((LocalVar "vec"), (TVector (4, (TInteger 32))))), - (TInteger 32), (Const (CInteger (32, 0L)))))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%result = insertelement <4 x i32> %vec, i32 1, i32 0 ; yields <4 x i32> "; - [%expect - {| - (Vector - (Insertelement ((LocalVar "result"), (TVector (4, (TInteger 32))), - (FromVariable ((LocalVar "vec"), (TVector (4, (TInteger 32))))), - (Const (CInteger (32, 1L))), (TInteger 32), (Const (CInteger (32, 0L))) - ))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - {| %result = shufflevector <4 x i32> %v1, <4 x i32> %v2, - <8 x i32> |}; - [%expect - {| - (Vector - (Shufflevector ((LocalVar "result"), (TVector (4, (TInteger 32))), - (FromVariable ((LocalVar "v1"), (TVector (4, (TInteger 32))))), - (FromVariable ((LocalVar "v2"), (TVector (4, (TInteger 32))))), 8, - (CVector - [(CInteger (32, 0L)); (CInteger (32, 1L)); (CInteger (32, 2L)); - (CInteger (32, 3L)); (CInteger (32, 4L)); (CInteger (32, 5L)); - (CInteger (32, 6L)); (CInteger (32, 7L))]) - ))) |}] -;; - -(* #############################################################*) -(* ##################### Aggregate #############################*) -(* #############################################################*) - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%result = extractvalue {i32, float} %agg, 0 ; yields i32"; - [%expect - {| - (Aggregate - (Extractvalue ((LocalVar "result"), (TStruct [(TInteger 32); TFloat]), - (FromVariable ((LocalVar "agg"), (TStruct [(TInteger 32); TFloat]))), - [0]))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%agg3 = insertvalue {i32, {float}} %agg1, float %val, 1, 0 "; - [%expect - {| - (Aggregate - (Insertvalue ((LocalVar "agg3"), - (TStruct [(TInteger 32); (TStruct [TFloat])]), - (FromVariable ((LocalVar "agg1"), - (TStruct [(TInteger 32); (TStruct [TFloat])]))), - TFloat, (FromVariable ((LocalVar "val"), TFloat)), [1; 0]))) |}] -;; - -(* ##########################################################*) -(* ################ MEMORY ADDRESS ##########################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %2 = alloca i32, align 4"; - [%expect - {| - (MemoryAddress - (Alloca ((LocalVar "2"), (TInteger 32), (Const (CInteger (1, 1L))), 4))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %2 = alloca i32"; - [%expect - {| - (MemoryAddress - (Alloca ((LocalVar "2"), (TInteger 32), (Const (CInteger (1, 1L))), 1))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %2 = alloca i32, i32 4, align 4"; - [%expect - {| - (MemoryAddress - (Alloca ((LocalVar "2"), (TInteger 32), (Const (CInteger (32, 4L))), 4))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %2 = alloca i32, i32 %kakadu"; - [%expect - {| - (MemoryAddress - (Alloca ((LocalVar "2"), (TInteger 32), - (FromVariable ((LocalVar "kakadu"), (TInteger 32))), 1))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction "%11 = load i32, ptr %3, align 4"; - [%expect - {| - (MemoryAddress - (Load ((LocalVar "11"), (TInteger 32), - (FromVariable ((LocalVar "3"), TPointer)), 4))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " store i32 %12, ptr %2, align 4"; - [%expect - {| - (MemoryAddress - (Store ((TInteger 32), (FromVariable ((LocalVar "12"), (TInteger 32))), - (FromVariable ((LocalVar "2"), TPointer)), 4))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%vptr = getelementptr {i32, <2 x i8>}, ptr %svptr, i64 0, i32 1, i32 1"; - [%expect - {| - (MemoryAddress - (Getelementptr ((LocalVar "vptr"), - (TStruct [(TInteger 32); (TVector (2, (TInteger 8)))]), TPointer, - (FromVariable ((LocalVar "svptr"), TPointer)), - [((TInteger 64), (Const (CInteger (64, 0L)))); - ((TInteger 32), (Const (CInteger (32, 1L)))); - ((TInteger 32), (Const (CInteger (32, 1L))))] - ))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - {| %vptr = getelementptr i32, <4 x ptr> %vs, <4 x i64> %vind1, - <4 x i32> , - <4 x i32> , - <4 x i32> %vind4, - <4 x i64> |}; - [%expect - {| - (MemoryAddress - (Getelementptr ((LocalVar "vptr"), (TInteger 32), (TVector (4, TPointer)), - (FromVariable ((LocalVar "vs"), (TVector (4, TPointer)))), - [((TVector (4, (TInteger 64))), - (FromVariable ((LocalVar "vind1"), (TVector (4, (TInteger 64)))))); - ((TVector (4, (TInteger 32))), - (Const - (CVector - [(CInteger (32, 2L)); (CInteger (32, 2L)); - (CInteger (32, 2L)); (CInteger (32, 2L))]))); - ((TVector (4, (TInteger 32))), - (Const - (CVector - [(CInteger (32, 1L)); (CInteger (32, 1L)); - (CInteger (32, 1L)); (CInteger (32, 1L))]))); - ((TVector (4, (TInteger 32))), - (FromVariable ((LocalVar "vind4"), (TVector (4, (TInteger 32)))))); - ((TVector (4, (TInteger 64))), - (Const - (CVector - [(CInteger (64, 13L)); (CInteger (64, 13L)); - (CInteger (64, 13L)); (CInteger (64, 13L))]))) - ] - ))) |}] -;; - -(* ##########################################################*) -(* #################### CONVERSION ##########################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %Y = inttoptr i32 255 to ptr"; - [%expect - {| - (Conversion - (InttoprtTo - ((LocalVar "Y"), (TInteger 32), (Const (CInteger (32, 255L))), TPointer))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction "%Y = fptoui float 1.0 to i1"; - [%expect - {| - (Conversion - (FptouiTo ((LocalVar "Y"), TFloat, (Const (CFloat 1.)), (TInteger 1)))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - "%Z = zext <2 x i16> to <2 x i32>"; - [%expect - {| - (Conversion - (ZextTo - ((LocalVar "Z"), (TVector (2, (TInteger 16))), - (Const (CVector [(CInteger (16, 8L)); (CInteger (16, 7L))])), - (TVector (2, (TInteger 32)))))) |}] -;; - -(* ##########################################################*) -(* ##################### OTHER ##############################*) -(* ##########################################################*) - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %5 = icmp slt i32 %4, 1"; - [%expect - {| - (Other - (Icmp ((LocalVar "5"), "slt", (TInteger 32), - (FromVariable ((LocalVar "4"), (TInteger 32))), - (Const (CInteger (32, 1L)))))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %10 = call i32 @fac(i32 %9) "; - [%expect - {| - (Other - (Call ((LocalVar "10"), (TInteger 32), - (Const (CPointer (PointerGlob (GlobalVar "fac")))), - [(FromVariable ((LocalVar "9"), (TInteger 32)))]))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction " %res = fcmp one float 4.0, 5.0"; - [%expect - {| - (Other - (Fcmp ((LocalVar "res"), "one", TFloat, (Const (CFloat 4.)), - (Const (CFloat 5.))))) |}] -;; - -let%expect_test _ = - test_parse - parse_instruction - Ast.show_instruction - " %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]"; - [%expect - {| - (Other - (Phi ((LocalVar "indvar"), (TInteger 32), - [((Const (CInteger (32, 0L))), - (FromVariable ((LocalVar "LoopHeader"), TLabel))); - ((FromVariable ((LocalVar "nextindvar"), (TInteger 32))), - (FromVariable ((LocalVar "Loop"), TLabel))) - ] - ))) |}] -;; - -let%expect_test _ = - test_parse parse_instruction Ast.show_instruction "%X = select i1 true, i8 17, i8 42"; - [%expect - {| - (Other - (Select ((LocalVar "X"), (TInteger 1), (Const (CInteger (1, 1L))), - (TInteger 8), (Const (CInteger (8, 17L))), (Const (CInteger (8, 42L))) - ))) |}] -;; diff --git a/LLVM_IR/lib/parser/instructions.mli b/LLVM_IR/lib/parser/instructions.mli deleted file mode 100644 index 11bece195..000000000 --- a/LLVM_IR/lib/parser/instructions.mli +++ /dev/null @@ -1,6 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val parse_instruction : Ast.instruction Angstrom.t -val parse_align : int Angstrom.t diff --git a/LLVM_IR/lib/parser/parsing.ml b/LLVM_IR/lib/parser/parsing.ml deleted file mode 100644 index 37b0ac6d1..000000000 --- a/LLVM_IR/lib/parser/parsing.ml +++ /dev/null @@ -1,117 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Angstrom -open CommonParser -open Types -open Values - -type func_annotation = - { self : Ast.variable - ; tp : Ast.tp - ; parameters : Ast.variable list - } -[@@deriving show { with_path = false }] - -let parse_function_annotation = - lift3 - (fun ret name args -> - let arg_types = - List.map - (function - | tp, _ -> tp) - args - in - let arg_vars = - List.map - (function - | _, var -> var) - args - in - { self = name; parameters = arg_vars; tp = Ast.TFunc (ret, arg_types) }) - (whitespaces *> parse_additional_type) - parse_global_variable - (whitespaces - *> char '(' - *> sep_by - comma - (whitespaces - *> lift2 (fun tp name -> tp, name) parse_main_type parse_local_variable) - <* whitespaces - <* char ')') -;; - -let%expect_test _ = - test_parse parse_function_annotation show_func_annotation "i32 @fac(i32 %0, i34 %1)"; - [%expect - {| - { self = (GlobalVar "fac"); - tp = (TFunc ((TInteger 32), [(TInteger 32); (TInteger 34)])); - parameters = [(LocalVar "0"); (LocalVar "1")] } |}] -;; - -let parse_basic_block_variable = - whitespaces *> parse_name <* whitespaces <* char ':' >>| fun name -> Ast.LocalVar name -;; - -let parse_basic_block_body = - let rec help lst = - Instructions.parse_instruction - >>= fun instr -> - match instr with - | Ast.Terminator _ -> return (instr :: lst) - | _ -> help (instr :: lst) - in - help [] >>| List.rev -;; - -let parse_start_basic_block = - lift2 - (fun self instructions -> self, Ast.CLabel instructions) - (parse_basic_block_variable <|> return (Ast.LocalVar "")) - parse_basic_block_body -;; - -let parse_basic_block = - lift2 - (fun self instructions -> self, Ast.CLabel instructions) - parse_basic_block_variable - parse_basic_block_body -;; - -let parse_function_body = - whitespaces - *> char '{' - *> whitespaces - *> lift2 (fun h tl -> h :: tl) parse_start_basic_block (many parse_basic_block) - <* whitespaces - <* char '}' -;; - -let parse_function = - whitespaces *> word "define" *> parse_function_annotation - >>= fun annot -> - parse_function_body - >>= fun bbs -> - return - ( annot.tp - , annot.self - , Ast.CFunc - ({ ftp = annot.tp; parameters = annot.parameters; basic_blocks = bbs } : Ast.func) - , 1 ) -;; - -let parse_glob_var = - let* variable = whitespaces *> parse_global_variable <* whitespaces <* char '=' in - let* tp = whitespaces *> word "global" *> whitespaces *> parse_main_type in - let* const = whitespaces *> parse_const tp in - let* alignment = Instructions.parse_align in - return (tp, variable, const, alignment) -;; - -let start_parse : Ast.glob_list t = - many (choice [ parse_function; parse_glob_var ]) <* whitespaces -;; - -let parse_program prog = Angstrom.parse_string ~consume:Consume.All start_parse prog diff --git a/LLVM_IR/lib/parser/parsing.mli b/LLVM_IR/lib/parser/parsing.mli deleted file mode 100644 index 9c0354123..000000000 --- a/LLVM_IR/lib/parser/parsing.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val parse_program : string -> (Ast.glob_list, string) result diff --git a/LLVM_IR/lib/parser/types.ml b/LLVM_IR/lib/parser/types.ml deleted file mode 100644 index 8cc3e1a0d..000000000 --- a/LLVM_IR/lib/parser/types.ml +++ /dev/null @@ -1,114 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Angstrom -open CommonParser - -let parse_primitive_type = - whitespaces - *> (char 'i' *> parse_integer - >>= (fun size -> return (Ast.TInteger size)) - <|> (parse_word - >>= function - | "float" -> return Ast.TFloat - | "ptr" -> return Ast.TPointer - | _ -> fail "Parsing error: unknown primitive type")) -;; - -let%expect_test _ = - test_parse parse_primitive_type Ast.show_tp "i64"; - [%expect {| (TInteger 64) |}] -;; - -let%expect_test _ = - test_parse parse_primitive_type Ast.show_tp " i2 "; - [%expect {| (TInteger 2) |}] -;; - -let%expect_test _ = - test_parse parse_primitive_type Ast.show_tp " c2 "; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse parse_primitive_type Ast.show_tp "float"; - [%expect {| TFloat |}] -;; - -let parse_main_type = - fix (fun parse_type -> - let parse_array_type = - whitespaces - *> char '[' - *> whitespaces - *> lift2 - (fun size t -> Ast.TArr (size, t)) - (parse_integer <* whitespaces <* char 'x') - (parse_type <* whitespaces <* char ']') - and parse_vector_type = - whitespaces - *> char '<' - *> whitespaces - *> lift2 - (fun size t -> Ast.TVector (size, t)) - (parse_integer <* whitespaces <* char 'x') - (parse_primitive_type <* whitespaces <* char '>') - and parse_structure_type = - lift3 - (fun h tl _ -> Ast.TStruct (List.cons h tl)) - (whitespaces *> char '{' *> whitespaces *> parse_type) - (many (comma *> parse_type)) - (whitespaces *> char '}') - in - choice - [ parse_primitive_type; parse_vector_type; parse_array_type; parse_structure_type ]) -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "<4xi32>"; - [%expect {| (TVector (4, (TInteger 32))) |}] -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "[4x[5x<4 x ptr>]]"; - [%expect {| (TArr (4, (TArr (5, (TVector (4, TPointer)))))) |}] -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "{i32, i42, float}"; - [%expect {| (TStruct [(TInteger 32); (TInteger 42); TFloat]) |}] -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "{ [4x{i34}], float}"; - [%expect {| (TStruct [(TArr (4, (TStruct [(TInteger 34)]))); TFloat]) |}] -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "{ , float}"; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse parse_main_type Ast.show_tp "{i32, i42,\n ;some comment \n float}"; - [%expect {| (TStruct [(TInteger 32); (TInteger 42); TFloat]) |}] -;; - -let parse_additional_type = - whitespaces - *> choice - [ parse_main_type - ; (parse_word - >>= function - | "void" -> return Ast.TVoid - | "label" -> return Ast.TLabel - | _ -> fail "Parsing error: unknown type") - ] -;; - -let additional_type tp = - parse_additional_type - >>= fun parsed_tp -> - if tp = parsed_tp then return tp else fail "Parser error: get unexpected type" -;; diff --git a/LLVM_IR/lib/parser/types.mli b/LLVM_IR/lib/parser/types.mli deleted file mode 100644 index 21bb0a6a4..000000000 --- a/LLVM_IR/lib/parser/types.mli +++ /dev/null @@ -1,8 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val parse_primitive_type : Ast.tp Angstrom.t -val parse_main_type : Ast.tp Angstrom.t -val parse_additional_type : Ast.tp Angstrom.t -val additional_type : Ast.tp -> Ast.tp Angstrom.t diff --git a/LLVM_IR/lib/parser/values.ml b/LLVM_IR/lib/parser/values.ml deleted file mode 100644 index d663636c5..000000000 --- a/LLVM_IR/lib/parser/values.ml +++ /dev/null @@ -1,218 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Angstrom -open CommonParser -open Types - -let rec parse_const tp = - let rec makeList i arg = if i = 0 then [] else arg :: makeList (i - 1) arg in - match tp with - | Ast.TVoid -> return Ast.CVoid - | Ast.TInteger size -> parse_const_integer size - | Ast.TFloat -> parse_const_float - | Ast.TPointer -> parse_const_pointer - | Ast.TVector (size, vtp) -> - parse_const_aggregate_type '<' '>' (makeList size vtp) - >>= fun lst -> return (Ast.CVector lst) - | Ast.TArr (size, atp) -> - parse_const_aggregate_type '[' ']' (makeList size atp) - >>= fun lst -> return (Ast.CArr lst) - | Ast.TStruct slst -> - parse_const_aggregate_type '{' '}' slst >>= fun lst -> return (Ast.CStruct lst) - | _ -> fail "Parser error: Get unknown type" - -and parse_const_aggregate_type ob cb tp_list = - char ob - *> whitespaces - *> sep_by - comma - (whitespaces *> parse_main_type - >>= fun tp -> whitespaces *> parse_const tp >>| fun c -> tp, c) - <* whitespaces - <* char cb - >>= fun lst -> - let readed_types = - List.map - (function - | tp, _ -> tp) - lst - in - let consts = - List.map - (function - | _, c -> c) - lst - in - if List.equal Ast.equal_tp readed_types tp_list - then return consts - else fail "Parser error: constant vector/array length mismatch" - -and parse_const_array size vector_tp = - char '<' - *> whitespaces - *> sep_by - comma - (whitespaces *> parse_main_type - >>= fun tp -> - whitespaces - *> - if vector_tp = tp - then parse_const tp - else fail "Parser error: constant vector type mismatch") - <* whitespaces - <* char '>' - >>= fun lst -> - if List.length lst = size - then return (Ast.CVector lst) - else fail "Parser error: constant vector length mismatch" - -and parse_const_pointer = - parse_global_variable - >>| (fun var -> Ast.CPointer (Ast.PointerGlob var)) - <|> word "null" *> return (Ast.CPointer (Ast.PointerInt 0)) - -and parse_const_float = - parse_word - >>= fun str -> - match Float.of_string_opt str with - | Some res -> return (Ast.CFloat res) - | None -> fail "Can't parse float" - -and parse_const_integer size = - choice - [ (let* sign = choice [ char '-' *> return (-1L); return 1L ] in - parse_integer64 >>| fun value -> Common.IrInts.create (Int64.mul sign value) size) - ; (if size = 1 - then - choice - [ word "true" *> return (Common.IrInts.create 1L size) - ; word "false" *> return (Common.IrInts.create 0L size) - ] - else fail "Parser error: can't parse i1 const") - ] -;; - -let parse_value tp = - whitespaces - *> choice - [ (parse_local_variable >>| fun var -> Ast.FromVariable (var, tp)) - ; (parse_const tp >>| fun const -> Ast.Const const) - ] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "void "; - [%expect {| (Const CVoid) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "float 2.3 "; - [%expect {| (Const (CFloat 2.3)) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "i1 432 "; - [%expect {| (Const (CInteger (1, 0L))) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "ptr @G "; - [%expect {| (Const (CPointer (PointerGlob (GlobalVar "G")))) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "{i32, float} { i32 4, float 17.0} "; - [%expect {| (Const (CStruct [(CInteger (32, 4L)); (CFloat 17.)])) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "<4 x i32> < i32 42, i32 11, i32 74, i32 100 > "; - [%expect - {| - (Const - (CVector - [(CInteger (32, 42L)); (CInteger (32, 11L)); (CInteger (32, 74L)); - (CInteger (32, 100L))])) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "[2 x [2 x i32]] [[2 x i32] [i32 1, i32 3], [2 x i32] [i32 2, i32 4]] "; - [%expect - {| - (Const - (CArr - [(CArr [(CInteger (32, 1L)); (CInteger (32, 3L))]); - (CArr [(CInteger (32, 2L)); (CInteger (32, 4L))])])) |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "{i32, int43} { i32 4, float 17.0} "; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "<4 x i32> < i32 42, i32 11, i32 100 > "; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "[2 x [2 x i32]] [[2 x i32] [i32 1, i31 3], [2 x i32] [i32 2, i32 4]] "; - [%expect {| Error |}] -;; - -let%expect_test _ = - test_parse - (parse_additional_type <* whitespaces >>= fun f -> parse_value f) - Ast.show_value - "i32 %12 "; - [%expect {| (FromVariable ((LocalVar "12"), (TInteger 32))) |}] -;; - -let parse_type_with_value = - parse_additional_type >>= fun tp -> parse_value tp >>| fun value -> tp, value -;; - -let parse_type_with_value2 = - parse_additional_type - >>= fun tp -> - parse_value tp >>= fun v1 -> comma *> parse_value tp >>| fun v2 -> tp, v1, v2 -;; - -let type_with_value tp = - parse_type_with_value - >>= function - | parsed_type, value when parsed_type = tp -> return value - | _ -> fail "Parser error: get unexpected type" -;; diff --git a/LLVM_IR/lib/parser/values.mli b/LLVM_IR/lib/parser/values.mli deleted file mode 100644 index 57f2f436b..000000000 --- a/LLVM_IR/lib/parser/values.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2023-2024, Efremov Alexey *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -val parse_const : Ast.tp -> Ast.const Angstrom.t -val parse_value : Ast.tp -> Ast.value Angstrom.t -val parse_type_with_value : (Ast.tp * Ast.value) Angstrom.t -val parse_type_with_value2 : (Ast.tp * Ast.value * Ast.value) Angstrom.t -val type_with_value : Ast.tp -> Ast.value Angstrom.t diff --git a/Lambda/.gitignore b/Lambda/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Lambda/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Lambda/.ocamlformat b/Lambda/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Lambda/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Lambda/COPYING b/Lambda/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Lambda/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Lambda/COPYING.CC0 b/Lambda/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Lambda/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Lambda/COPYING.LESSER b/Lambda/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Lambda/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Lambda/DONT_REMOVE_THIS_DIRECTORY.md b/Lambda/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Lambda/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Lambda/Lambda.opam b/Lambda/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/Lambda/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Lambda/Makefile b/Lambda/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Lambda/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Lambda/README.md b/Lambda/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/Lambda/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Lambda/REPL.ml b/Lambda/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Lambda/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Lambda/demos/demoAO.ml b/Lambda/demos/demoAO.ml deleted file mode 100644 index 346f3d1ee..000000000 --- a/Lambda/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> Format.printf "%a\n%!" Pprintast.pp - let () = test ao_strat @@ one |> Format.printf "%a\n%!" Pprintast.pp - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Lambda/demos/demoNO.ml b/Lambda/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Lambda/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Lambda/demos/demoParse.ml b/Lambda/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Lambda/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Lambda/demos/demo_input.txt b/Lambda/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Lambda/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Lambda/demos/dune b/Lambda/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Lambda/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Lambda/demos/interpretTests.t b/Lambda/demos/interpretTests.t deleted file mode 100644 index 7dd974826..000000000 --- a/Lambda/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2023, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Lambda/demos/parsingTests.t b/Lambda/demos/parsingTests.t deleted file mode 100644 index f27aa3941..000000000 --- a/Lambda/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2023, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Lambda/dune b/Lambda/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Lambda/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Lambda/dune-project b/Lambda/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/Lambda/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Lambda/lib/Pprintast.ml b/Lambda/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Lambda/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Lambda/lib/Pprintast.mli b/Lambda/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Lambda/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Lambda/lib/Printast.ml b/Lambda/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Lambda/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Lambda/lib/Printast.mli b/Lambda/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Lambda/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Lambda/lib/ast.mli b/Lambda/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Lambda/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Lambda/lib/dune b/Lambda/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Lambda/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Lambda/lib/interpret.ml b/Lambda/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Lambda/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Lambda/lib/interpret.mli b/Lambda/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Lambda/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Lambda/lib/lambda.ml b/Lambda/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Lambda/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Lambda/lib/lambda.mli b/Lambda/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Lambda/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Lambda/lib/parser.ml b/Lambda/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Lambda/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Lambda/lib/parser.mli b/Lambda/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Lambda/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Lambda/lib/tests.ml b/Lambda/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Lambda/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Lambda/lib/utils.ml b/Lambda/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Lambda/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Lambda/lib/utils.mli b/Lambda/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Lambda/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Lambda/repl.t b/Lambda/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Lambda/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/Lua/.gitignore b/Lua/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Lua/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Lua/.ocamlformat b/Lua/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Lua/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Lua/COPYING b/Lua/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Lua/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Lua/COPYING.CC0 b/Lua/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Lua/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Lua/COPYING.LESSER b/Lua/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Lua/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Lua/DONT_REMOVE_THIS_DIRECTORY.md b/Lua/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Lua/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Lua/Lambda.opam b/Lua/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/Lua/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Lua/Makefile b/Lua/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Lua/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Lua/README.md b/Lua/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/Lua/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Lua/REPL.ml b/Lua/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Lua/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Lua/demos/demoAO.ml b/Lua/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/Lua/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Lua/demos/demoNO.ml b/Lua/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Lua/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Lua/demos/demoParse.ml b/Lua/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Lua/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Lua/demos/demo_input.txt b/Lua/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Lua/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Lua/demos/dune b/Lua/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Lua/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Lua/demos/interpretTests.t b/Lua/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/Lua/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Lua/demos/parsingTests.t b/Lua/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/Lua/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Lua/dune b/Lua/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Lua/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Lua/dune-project b/Lua/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/Lua/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Lua/lib/Pprintast.ml b/Lua/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Lua/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Lua/lib/Pprintast.mli b/Lua/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Lua/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Lua/lib/Printast.ml b/Lua/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Lua/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Lua/lib/Printast.mli b/Lua/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Lua/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Lua/lib/ast.mli b/Lua/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Lua/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Lua/lib/dune b/Lua/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Lua/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Lua/lib/interpret.ml b/Lua/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Lua/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Lua/lib/interpret.mli b/Lua/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Lua/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Lua/lib/lambda.ml b/Lua/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Lua/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Lua/lib/lambda.mli b/Lua/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Lua/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Lua/lib/parser.ml b/Lua/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Lua/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Lua/lib/parser.mli b/Lua/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Lua/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Lua/lib/tests.ml b/Lua/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Lua/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Lua/lib/utils.ml b/Lua/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Lua/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Lua/lib/utils.mli b/Lua/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Lua/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Lua/repl.t b/Lua/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Lua/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/Menhir/.gitignore b/Menhir/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Menhir/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Menhir/.ocamlformat b/Menhir/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Menhir/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Menhir/COPYING b/Menhir/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Menhir/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Menhir/COPYING.CC0 b/Menhir/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Menhir/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Menhir/COPYING.LESSER b/Menhir/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Menhir/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Menhir/DONT_REMOVE_THIS_DIRECTORY.md b/Menhir/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Menhir/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Menhir/Lambda.opam b/Menhir/Lambda.opam deleted file mode 100644 index d7876f718..000000000 --- a/Menhir/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Maxim Chizhov"] -authors: ["Maxim Chizhov"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Menhir/Makefile b/Menhir/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Menhir/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Menhir/README.md b/Menhir/README.md deleted file mode 100644 index 1f01931ff..000000000 --- a/Menhir/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Maxim Chizhov, gladiuswq@proton.me - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Menhir/REPL.ml b/Menhir/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Menhir/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Menhir/demos/demoAO.ml b/Menhir/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/Menhir/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Menhir/demos/demoNO.ml b/Menhir/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Menhir/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Menhir/demos/demoParse.ml b/Menhir/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Menhir/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Menhir/demos/demo_input.txt b/Menhir/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Menhir/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Menhir/demos/dune b/Menhir/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Menhir/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Menhir/demos/interpretTests.t b/Menhir/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/Menhir/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Menhir/demos/parsingTests.t b/Menhir/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/Menhir/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Menhir/dune b/Menhir/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Menhir/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Menhir/dune-project b/Menhir/dune-project deleted file mode 100644 index e16ca1b33..000000000 --- a/Menhir/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Maxim Chizhov") - -(maintainers "Maxim Chizhov") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Menhir/lib/Pprintast.ml b/Menhir/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Menhir/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Menhir/lib/Pprintast.mli b/Menhir/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Menhir/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Menhir/lib/Printast.ml b/Menhir/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Menhir/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Menhir/lib/Printast.mli b/Menhir/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Menhir/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Menhir/lib/ast.mli b/Menhir/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Menhir/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Menhir/lib/dune b/Menhir/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Menhir/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Menhir/lib/interpret.ml b/Menhir/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Menhir/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Menhir/lib/interpret.mli b/Menhir/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Menhir/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Menhir/lib/lambda.ml b/Menhir/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Menhir/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Menhir/lib/lambda.mli b/Menhir/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Menhir/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Menhir/lib/parser.ml b/Menhir/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Menhir/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Menhir/lib/parser.mli b/Menhir/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Menhir/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Menhir/lib/tests.ml b/Menhir/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Menhir/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Menhir/lib/utils.ml b/Menhir/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Menhir/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Menhir/lib/utils.mli b/Menhir/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Menhir/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Menhir/repl.t b/Menhir/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Menhir/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/OCaml+PolymorphicVariants/.gitignore b/OCaml+PolymorphicVariants/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/OCaml+PolymorphicVariants/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/OCaml+PolymorphicVariants/.ocamlformat b/OCaml+PolymorphicVariants/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OCaml+PolymorphicVariants/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OCaml+PolymorphicVariants/COPYING b/OCaml+PolymorphicVariants/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OCaml+PolymorphicVariants/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OCaml+PolymorphicVariants/COPYING.CC0 b/OCaml+PolymorphicVariants/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OCaml+PolymorphicVariants/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OCaml+PolymorphicVariants/COPYING.LESSER b/OCaml+PolymorphicVariants/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OCaml+PolymorphicVariants/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OCaml+PolymorphicVariants/Makefile b/OCaml+PolymorphicVariants/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OCaml+PolymorphicVariants/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OCaml+PolymorphicVariants/OCaml+PolymorphicVariants.opam b/OCaml+PolymorphicVariants/OCaml+PolymorphicVariants.opam deleted file mode 100644 index dcb3771e2..000000000 --- a/OCaml+PolymorphicVariants/OCaml+PolymorphicVariants.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for OCaml with polymorphic variants" -description: - "A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Nikita Nemakin"] -authors: ["Nikita Nemakin"] -license: "LGPL-3.0-or-later" -homepage: "github.com/nemakin/fp2023" -bug-reports: "nikita.nemakin@yandex.ru" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCaml+PolymorphicVariants/README.md b/OCaml+PolymorphicVariants/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/OCaml+PolymorphicVariants/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/OCaml+PolymorphicVariants/demos/demoParse.ml b/OCaml+PolymorphicVariants/demos/demoParse.ml deleted file mode 100644 index 6708bc792..000000000 --- a/OCaml+PolymorphicVariants/demos/demoParse.ml +++ /dev/null @@ -1,13 +0,0 @@ -(** Copyright 2021-2022, Nikita Nemakin *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Ocaml_pv.Parser -open Ocaml_pv.Ast - -let () = - let res = parse "let rec fac n = if n < 2 then 1 else n * fac (n - 1) " in - match res with - | Ok ast -> Format.printf "%a\n%!" pp_structure ast - | Error msg -> Format.printf "Error %s\n" msg -;; diff --git a/OCaml+PolymorphicVariants/demos/demoParse.t b/OCaml+PolymorphicVariants/demos/demoParse.t deleted file mode 100644 index b079d0bbd..000000000 --- a/OCaml+PolymorphicVariants/demos/demoParse.t +++ /dev/null @@ -1,14 +0,0 @@ - $ dune exec demoParse - [(SValue (Rec, - ((PVar "fac"), - (EFun ((PVar "n"), - (EIf ((EBin_op (Lt, (EVar "n"), (EConst (CInt 2)))), - (EConst (CInt 1)), - (EBin_op (Mul, (EVar "n"), - (EApply ((EVar "fac"), - (EBin_op (Sub, (EVar "n"), (EConst (CInt 1)))))) - )) - )) - ))) - )) - ] diff --git a/OCaml+PolymorphicVariants/demos/dune b/OCaml+PolymorphicVariants/demos/dune deleted file mode 100644 index 01c1bd187..000000000 --- a/OCaml+PolymorphicVariants/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries OCaml+PolymorphicVariants.Lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demoParse})) diff --git a/OCaml+PolymorphicVariants/dune b/OCaml+PolymorphicVariants/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/OCaml+PolymorphicVariants/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/OCaml+PolymorphicVariants/dune-project b/OCaml+PolymorphicVariants/dune-project deleted file mode 100644 index 2d0d20354..000000000 --- a/OCaml+PolymorphicVariants/dune-project +++ /dev/null @@ -1,32 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Nikita Nemakin") - -(maintainers "Nikita Nemakin") - -(bug_reports "nikita.nemakin@yandex.ru") - -(homepage "") - -(package - (name OCaml+PolymorphicVariants) - (synopsis "An interpreter for OCaml with polymorphic variants") - (description - "A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - base)) diff --git a/OCaml+PolymorphicVariants/lib/ast.ml b/OCaml+PolymorphicVariants/lib/ast.ml deleted file mode 100644 index 2bfca2647..000000000 --- a/OCaml+PolymorphicVariants/lib/ast.ml +++ /dev/null @@ -1,72 +0,0 @@ -(** Copyright 2021-2023, Nikita Nemakin *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** (a-z|_) {a-z|0-9|_}*) -type id = string [@@deriving show { with_path = false }] - -(** Used in {let} expr *) -type rec_flag = - | Rec - | Nonrec -[@@deriving show { with_path = false }] - -type bin_op = - | Mul (** * *) - | Div (** / *) - | Add (** + *) - | Sub (** - *) - | Eq (** = *) - | Neq (** <> *) - | Lt (** < *) - | Lte (** <= *) - | Gt (** > *) - | Gte (** >= *) - | And (** && *) - | Or (** || *) -[@@deriving show { with_path = false }] - -type const = - | CInt of int (** 123 *) - | CBool of bool (** true | false *) - | CString of string (** "string" *) - | CUnit (** () *) - | CNil (** [] *) -[@@deriving show { with_path = false }] - -type pattern = - | PAny (** _ *) - | PConst of const (** 123, true, "string" *) - | PVar of id (** x *) - | PTuple of pattern list (** p1,..., pn *) - | PCons of pattern * pattern (** p1 :: p2 *) - | PPoly of id * pattern option (** `Tag_name p *) -[@@deriving show { with_path = false }] - -type expr = - | EConst of const (** 123, true, "string" *) - | EVar of id (** x *) - | EBin_op of bin_op * expr * expr (** 1 + 2 *) - | EIf of expr * expr * expr (** if e1 then e2 else e3 *) - | EMatch of expr * case list (** match e with p1 -> e1 |...| pn -> en *) - | ELet of rec_flag * binding * expr (** let x = e1 in e2 *) - | EFun of pattern * expr (** fun p -> e *) - | ETuple of expr list (** a, b, c *) - | ECons of expr * expr (** x :: xs | [x1; x2]*) - | EApply of expr * expr (** f e *) - | EPoly of id * expr option (** `Tag_name expr *) -[@@deriving show { with_path = false }] - -(** Used in {match} expr *) -and case = pattern * expr [@@deriving show { with_path = false }] - -(** Used in {let} expr *) -and binding = pattern * expr [@@deriving show { with_path = false }] - -type str_item = - | SEval of expr (** Some expression *) - | SValue of rec_flag * binding (** let [rec] p = e *) -[@@deriving show { with_path = false }] - -(** Sequence of structure items *) -type structure = str_item list [@@deriving show { with_path = false }] diff --git a/OCaml+PolymorphicVariants/lib/dune b/OCaml+PolymorphicVariants/lib/dune deleted file mode 100644 index cc4076c93..000000000 --- a/OCaml+PolymorphicVariants/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name ocaml_pv) - (public_name OCaml+PolymorphicVariants.Lib) - (modules Ast Parser) - (inline_tests) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) diff --git a/OCaml+PolymorphicVariants/lib/parser.ml b/OCaml+PolymorphicVariants/lib/parser.ml deleted file mode 100644 index 1a58fe6e2..000000000 --- a/OCaml+PolymorphicVariants/lib/parser.ml +++ /dev/null @@ -1,478 +0,0 @@ -(** Copyright 2021-2023, Nikita Nemakin *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Angstrom - -let is_idc c = Char.is_alphanum c || Char.equal c '_' - -let is_keyword = function - | "let" - | "rec" - | "in" - | "fun" - | "match" - | "with" - | "if" - | "then" - | "else" - | "true" - | "false" -> true - | _ -> false -;; - -let ws = take_while Char.is_whitespace -let token s = ws *> string s -let lp = token "(" -let rp = token ")" -let lsb = token "[" -let rsb = token "]" -let semi = token ";" -let dsemi = token ";;" -let dcol = token "::" -let comma = token "," -let grd = token "|" -let arr = token "->" -let parens p = lp *> p <* rp -let brackets p = lsb *> p <* rsb - -(*--------------------------------- Constants --------------------------------*) - -let cint i = CInt i -let cbool b = CBool b -let cstring s = CString s - -let pcint = - let* sign = choice [ token "-"; token "+"; token "" ] in - let* num = take_while1 Char.is_digit in - return @@ Int.of_string (sign ^ num) >>| cint -;; - -let pcbool = - let t = token "true" *> return (cbool true) in - let f = token "false" *> return (cbool false) in - choice [ t; f ] -;; - -let pcstring = - token "\"" - *> take_while (function - | '"' -> false - | _ -> true) - <* char '"' - >>| cstring -;; - -let pcunit = token "()" *> return CUnit -let pcnil = token "[]" *> return CNil -let const = choice [ pcint; pcbool; pcstring; pcunit; pcnil ] - -(*------------------------------ Patterns ------------------------------------*) - -let pconst c = PConst c -let pvar x = PVar x -let ppoly t p = PPoly (t, p) -let pcons p1 p2 = PCons (p1, p2) -let ptuple ps = PTuple ps -let ppoly t p = PPoly (t, p) -let ppconst = const >>| pconst -let ppany = token "_" *> return PAny - -let varname = - let* fst = - ws - *> satisfy (function - | 'a' .. 'z' | '_' -> true - | _ -> false) - in - let* rest = take_while is_idc in - match String.of_char fst ^ rest with - | "_" -> fail "Wildcard can't be used as indetifier" - | s when is_keyword s -> fail "Keyword can't be used as identifier" - | _ as name -> return name -;; - -let tagname = - let* fst = token "`" *> satisfy Char.is_uppercase in - let* rest = take_while is_idc in - return @@ String.of_char fst ^ rest -;; - -let ppvar = varname >>| pvar -let pppoly p = lift2 ppoly tagname (option None (p >>| fun p -> Some p)) -let pptuple p = lift2 List.cons p (many1 (comma *> p)) >>| ptuple -let pplist p = brackets @@ sep_by1 semi p >>| List.fold_right ~f:pcons ~init:(pconst CNil) - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= go -;; - -let chainr1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op (e >>= go) <|> return acc in - e >>= go -;; - -type pdispatch = - { pat : pdispatch -> pattern t - ; tuple : pdispatch -> pattern t - ; poly : pdispatch -> pattern t - ; cons : pdispatch -> pattern t - } - -let pack = - let pat pack = - fix (fun _ -> choice [ pack.tuple pack; pack.cons pack; pack.poly pack ]) - in - let term pack = - choice - [ pack.poly pack - ; ppconst - ; ppvar - ; ppany - ; pplist @@ pack.pat pack - ; parens @@ pack.pat pack - ] - in - let tuple pack = fix (fun _ -> pptuple @@ pack.cons pack) in - let poly pack = fix (fun _ -> pppoly @@ term pack) in - let cons pack = fix (fun _ -> chainr1 (term pack) (dcol *> return pcons)) in - { pat; tuple; poly; cons } -;; - -let pattern = pack.pat pack - -(*----------------------------- Expressions ----------------------------------*) -let econst c = EConst c -let evar x = EVar x -let ebinop op e1 e2 = EBin_op (op, e1, e2) -let eif e1 e2 e3 = EIf (e1, e2, e3) -let ematch e cl = EMatch (e, cl) -let elet f b e = ELet (f, b, e) -let efun p e = EFun (p, e) -let etuple el = ETuple el -let econs e1 e2 = ECons (e1, e2) -let eapply e1 e2 = EApply (e1, e2) -let epoly t e = EPoly (t, e) -let peconst = const >>| econst -let pevar = varname >>| evar -let peif p = lift3 eif (token "if" *> p) (token "then" *> p) (token "else" *> p) - -let pematch pe = - let pexpr = token "match" *> pe <* token "with" <* option "" grd in - let pcase = lift2 (fun p e -> p, e) (pattern <* arr) pe in - lift2 ematch pexpr (sep_by1 grd pcase) -;; - -let pepoly p = lift2 epoly tagname (option None (p >>| fun e -> Some e)) -let petuple p = lift2 List.cons p (many1 (comma *> p)) >>| etuple -let pelist p = brackets @@ sep_by1 semi p >>| List.fold_right ~f:econs ~init:(econst CNil) -let efunf ps e = List.fold_right ps ~f:efun ~init:e -let pefun pe = lift2 efun (token "fun" *> pattern) (lift2 efunf (many pattern <* arr) pe) - -let pelet pe = - lift3 - elet - (token "let" *> option Nonrec (token "rec" *> return Rec)) - (both pattern (lift2 efunf (many pattern <* token "=") pe)) - (token "in" *> pe) -;; - -let pmul = token "*" *> return (ebinop Mul) -let pdiv = token "/" *> return (ebinop Div) -let padd = token "+" *> return (ebinop Add) -let psub = token "-" *> return (ebinop Sub) -let peq = token "=" *> return (ebinop Eq) -let plt = token "<" *> return (ebinop Lt) -let plte = token "<=" *> return (ebinop Lte) -let pneq = token "<>" *> return (ebinop Neq) -let pgt = token ">" *> return (ebinop Gt) -let pgte = token ">=" *> return (ebinop Gte) -let pand = token "&&" *> return (ebinop And) -let por = token "||" *> return (ebinop Or) - -(* - fun apply, tag apply left - * / left - + - left - :: right - = <... left - >... left - && right - || right - if - - let match fun - -*) - -let expr = - fix (fun expr -> - let expr = choice [ peconst; pevar; pelist expr; parens expr ] in - let expr = pepoly expr <|> expr in - let expr = chainl1 expr (return eapply) in - let expr = chainl1 expr (pmul <|> pdiv) in - let expr = chainl1 expr (padd <|> psub) in - let expr = chainr1 expr (dcol *> return econs) in - let expr = chainl1 expr (choice [ plte; plt; pneq; peq ]) in - let expr = chainl1 expr (pgt <|> pgte) in - let expr = chainr1 expr pand in - let expr = chainr1 expr por in - let expr = petuple expr <|> expr in - let expr = peif expr <|> expr in - let expr = choice [ pelet expr; pematch expr; pefun expr; expr ] in - expr) -;; - -(*----------------------------- Structure ------------------------------------*) - -let str_item = - let pseval = expr >>| fun e -> SEval e in - let svalue f b = SValue (f, b) in - let psvalue = - lift2 - svalue - (token "let" *> option Nonrec (token "rec" *> return Rec)) - (both pattern (lift2 efunf (many pattern <* token "=") expr)) - in - choice [ pseval; psvalue ] -;; - -let structure : structure t = sep_by dsemi str_item -let parse s = parse_string ~consume:Prefix structure s -(*-------------------------------- Tests -------------------------------------*) - -let test_parse p to_str input = - let parse p s = parse_string ~consume:Prefix p s in - match parse p input with - | Ok ast -> Format.printf "%s\n" (to_str ast) - | Error s -> Format.printf "%s\n" s -;; - -let%expect_test _ = - test_parse pattern show_pattern "123"; - [%expect {| (PConst (CInt 123)) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern "_"; - [%expect {| PAny |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern "_A"; - [%expect {| (PVar "_A") |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern "true"; - [%expect {| (PConst (CBool true)) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern "\"true\""; - [%expect {| (PConst (CString "true")) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [] "; - [%expect {| (PConst CNil) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " () "; - [%expect {| (PConst CUnit) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A "; - [%expect {| (PPoly ("A", None)) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A `B "; - [%expect {| (PPoly ("A", (Some (PPoly ("B", None))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A 123 "; - [%expect {| (PPoly ("A", (Some (PConst (CInt 123))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " 123, 321 "; - [%expect {| (PTuple [(PConst (CInt 123)); (PConst (CInt 321))]) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [123] "; - [%expect {| (PCons ((PConst (CInt 123)), (PConst CNil))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [1; 2; 3] "; - [%expect - {| - (PCons ((PConst (CInt 1)), - (PCons ((PConst (CInt 2)), (PCons ((PConst (CInt 3)), (PConst CNil))))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [1, 2; 3, 4] "; - [%expect - {| - (PCons ((PTuple [(PConst (CInt 1)); (PConst (CInt 2))]), - (PCons ((PTuple [(PConst (CInt 3)); (PConst (CInt 4))]), (PConst CNil))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A 123 "; - [%expect {| (PPoly ("A", (Some (PConst (CInt 123))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " 123, 321 "; - [%expect {| (PTuple [(PConst (CInt 123)); (PConst (CInt 321))]) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [123] "; - [%expect {| (PCons ((PConst (CInt 123)), (PConst CNil))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [1; 2; 3] "; - [%expect - {| - (PCons ((PConst (CInt 1)), - (PCons ((PConst (CInt 2)), (PCons ((PConst (CInt 3)), (PConst CNil))))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [1, 2; 3, 4] "; - [%expect - {| - (PCons ((PTuple [(PConst (CInt 1)); (PConst (CInt 2))]), - (PCons ((PTuple [(PConst (CInt 3)); (PConst (CInt 4))]), (PConst CNil))))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " [1; 2], [3; 4] "; - [%expect - {| - (PTuple - [(PCons ((PConst (CInt 1)), (PCons ((PConst (CInt 2)), (PConst CNil))))); - (PCons ((PConst (CInt 3)), (PCons ((PConst (CInt 4)), (PConst CNil)))))])|}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " 123 :: [] "; - [%expect {| - (PCons ((PConst (CInt 123)), (PConst CNil))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " _ :: _ :: _ "; - [%expect {| - (PCons (PAny, (PCons (PAny, PAny)))) |}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A 1, 2 "; - [%expect {| - (PTuple [(PPoly ("A", (Some (PConst (CInt 1))))); (PConst (CInt 2))])|}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A (1, 2) "; - [%expect {| - (PPoly ("A", (Some (PTuple [(PConst (CInt 1)); (PConst (CInt 2))]))))|}] -;; - -let%expect_test _ = - test_parse pattern show_pattern " `A 1 :: [`A 3] "; - [%expect - {| - (PCons ((PPoly ("A", (Some (PConst (CInt 1))))), - (PCons ((PPoly ("A", (Some (PConst (CInt 3))))), (PConst CNil)))))|}] -;; - -let%expect_test _ = - test_parse - structure - show_structure - {| let rec fac n = if n < 2 then 1 else n * fac(n - 1);; |}; - [%expect - {| - [(SValue (Rec, - ((PVar "fac"), - (EFun ((PVar "n"), - (EIf ((EBin_op (Lt, (EVar "n"), (EConst (CInt 2)))), - (EConst (CInt 1)), - (EBin_op (Mul, (EVar "n"), - (EApply ((EVar "fac"), - (EBin_op (Sub, (EVar "n"), (EConst (CInt 1)))))) - )) - )) - ))) - )) - ] |}] -;; - -let%expect_test _ = - test_parse - structure - show_structure - {| let f = let g x = x + 1 in g;; - - let rec len l = - match l with - | [] -> 0 - | _ :: xs -> 1 + len xs - ;; |}; - [%expect - {| - [(SValue (Nonrec, - ((PVar "f"), - (ELet (Nonrec, - ((PVar "g"), - (EFun ((PVar "x"), (EBin_op (Add, (EVar "x"), (EConst (CInt 1))))))), - (EVar "g")))) - )); - (SValue (Rec, - ((PVar "len"), - (EFun ((PVar "l"), - (EMatch ((EVar "l"), - [((PConst CNil), (EConst (CInt 0))); - ((PCons (PAny, (PVar "xs"))), - (EBin_op (Add, (EConst (CInt 1)), - (EApply ((EVar "len"), (EVar "xs")))))) - ] - )) - ))) - )) - ] |}] -;; - -let%expect_test _ = - test_parse - structure - show_structure - {| let f = (fun x -> x + 1) 123 in f;; - let x, y, z = (1, 2, 3);; |}; - [%expect - {| - [(SEval - (ELet (Nonrec, - ((PVar "f"), - (EApply ( - (EFun ((PVar "x"), (EBin_op (Add, (EVar "x"), (EConst (CInt 1)))) - )), - (EConst (CInt 123))))), - (EVar "f")))); - (SValue (Nonrec, - ((PTuple [(PVar "x"); (PVar "y"); (PVar "z")]), - (ETuple [(EConst (CInt 1)); (EConst (CInt 2)); (EConst (CInt 3))])) - )) - ] |}] -;; diff --git a/OCamlTyEff/.gitignore b/OCamlTyEff/.gitignore deleted file mode 100644 index 2c1f94e48..000000000 --- a/OCamlTyEff/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/macos,ocaml -# Edit at https://www.toptal.com/developers/gitignore?templates=macos,ocaml - -.vscode - -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### macOS Patch ### -# iCloud generated files -*.icloud - -### OCaml ### -*.annot -*.cmo -*.cma -*.cmi -*.a -*.o -*.cmx -*.cmxs -*.cmxa - -# ocamlbuild working directory -_build/ - -# ocamlbuild targets -*.byte -*.native - -# oasis generated files -setup.data -setup.log - -# Merlin configuring file for Vim and Emacs -.merlin - -# Dune generated files -*.install - -# Local OPAM switch -_opam/ - -# End of https://www.toptal.com/developers/gitignore/api/macos,ocaml -tmp diff --git a/OCamlTyEff/.ocamlformat b/OCamlTyEff/.ocamlformat deleted file mode 100644 index b423f40a0..000000000 --- a/OCamlTyEff/.ocamlformat +++ /dev/null @@ -1,2 +0,0 @@ -profile = ocamlformat -version = 0.26.1 diff --git a/OCamlTyEff/LICENSE b/OCamlTyEff/LICENSE deleted file mode 100644 index 8942c5ff3..000000000 --- a/OCamlTyEff/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Danil Slinchuk, Andrei Sukharev - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/OCamlTyEff/OCamlTyEff.opam b/OCamlTyEff/OCamlTyEff.opam deleted file mode 100644 index ee31bdc5c..000000000 --- a/OCamlTyEff/OCamlTyEff.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "OCaml interpreter with support for typed effects" -description: "OCaml interpreter with support for typed effects" -maintainer: [ - "Andrei " "Danil S " "Danil S = "3.7"} - "base" - "angstrom" - "ppx_deriving" - "ppx_expect" - "bisect_ppx" - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCamlTyEff/README.md b/OCamlTyEff/README.md deleted file mode 100644 index 872658f29..000000000 --- a/OCamlTyEff/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# OCamlTyEff - -Interpreter for a subset of OCaml language with support for typed effects - -## Typed effects - -WIP - -## Features - -### Parser - -- Structure items (top level statements) - - - [x] `let` value bindings - - [x] `rec` - - [x] `and` - - [x] `let f x = ..` - - [x] expressions - -- Constants - - - [x] integer, char constants - - [x] string constants `"helo world"` - - [ ] string constants `{|hello world|}` - - [ ] float constants - - [ ] `()` constant - - [ ] boolean constants - -- Expressions - - - [x] function application `f x y` - - [x] constants - - [x] `let .. in` value bindings - - [x] `if .. then .. else ..` - - [ ] anonymous functions - - [ ] `fun x y -> ..` - - [ ] `function` - - [x] lists - - [x] `[a; b; c]` - - [x] `::`, `[]` constructors - - [x] `match .. with ..` - - [x] constructors' application (`None`, `Some x`) - - [x] tuples `a, b, c` - - [x] sequences `a; b; c` - - [x] prefix and infix operators - - `let (+++) a b = a - b in 5 +++ 4` - - `let (?!) _ = failwith "?!" in ?!0` - - `a + b`, `(+) (-a) b` - -- Patterns - - [x] any `_` - - [x] variables `a` - - [x] constants - - [x] tuples `a, b` - - [x] or `a | b | c` - - [x] constructors' application `None`, `Some x`, `Cons (hd, tl)` - - [ ] lists - - [x] `::` constructor - - [ ] `[a;b;c]` - -### Type checker - -WIP - -### Interpreter - -WIP - -## Build & Run tests - -```bash -dune build -dune runtest -``` - -## License - -Distributed under the MIT License. See [LICENSE](LICENSE) for more information. diff --git a/OCamlTyEff/bin/dune b/OCamlTyEff/bin/dune deleted file mode 100644 index a7d5ecd1f..000000000 --- a/OCamlTyEff/bin/dune +++ /dev/null @@ -1,7 +0,0 @@ -(executable - (name interpret) - (public_name interpret) - (libraries base ast parser)) - -(cram - (deps ./interpret.exe %{bin:interpret})) diff --git a/OCamlTyEff/bin/interpret.ml b/OCamlTyEff/bin/interpret.ml deleted file mode 100644 index bfb0fe605..000000000 --- a/OCamlTyEff/bin/interpret.ml +++ /dev/null @@ -1,6 +0,0 @@ -open! Base - -let () = - In_channel.(input_all stdin) - |> Parser.parse_exn |> Ast.show_structure - |> Out_channel.(output_string stdout) diff --git a/OCamlTyEff/bin/interpret.t b/OCamlTyEff/bin/interpret.t deleted file mode 100644 index 8b8ba4883..000000000 --- a/OCamlTyEff/bin/interpret.t +++ /dev/null @@ -1,29 +0,0 @@ - $ ./interpret.exe < let rec fact n = if n < 2 then 1 else n * fact (n - 1) - [(Str_value (Recursive, - [{ pat = (Pat_var "fact"); - expr = - (Exp_function ([(Pat_var "n")], - (Function_body - (Exp_ifthenelse ( - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "<")), - (Exp_ident (Ident "n")))), - (Exp_constant (Const_integer 2)))), - (Exp_constant (Const_integer 1)), - (Some (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "*")), - (Exp_ident (Ident "n")))), - (Exp_apply ((Exp_ident (Ident "fact")), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "-")), - (Exp_ident (Ident "n")))), - (Exp_constant (Const_integer 1)))) - )) - ))) - ))) - )) - } - ] - )) - ] diff --git a/OCamlTyEff/dune b/OCamlTyEff/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/OCamlTyEff/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/OCamlTyEff/dune-project b/OCamlTyEff/dune-project deleted file mode 100644 index ca2b25628..000000000 --- a/OCamlTyEff/dune-project +++ /dev/null @@ -1,25 +0,0 @@ -(lang dune 3.7) - -(name OCamlTyEff) - -(generate_opam_files true) - -(cram enable) - -(authors "Andrei " "Danil S " - "Danil S = 2] *) - | Pat_or of pattern * pattern (** Pattern [P1 | P2] *) - | Pat_construct of ident * pattern option - (** [Pat_construct(C, args)] represents: - - [C] when [args] is [None] - - [C P] when [args] is [Some P] - *) -[@@deriving show {with_path= false}] - -(* ======= Expressions ======= *) - -type rec_flag = - | Recursive (** Recursive value binding *) - | Nonrecursive (** Nonrecursive value binding *) -[@@deriving show {with_path= false}] - -and value_binding = {pat: pattern; expr: expression} -[@@deriving show {with_path= false}] - -and function_body = - | Function_body of expression (** Expression as function body *) - | Function_cases of case list (** For functions defined using [function] *) -[@@deriving show {with_path= false}] - -(** Pattern matching case *) -and case = {left: pattern; right: expression} -[@@deriving show {with_path= false}] - -and expression = - | Exp_ident of ident (** Identifiers such as [x], [fact] *) - | Exp_constant of constant - (** Expression constant such as [1], ['a'], ["hello"], [1.5] *) - | Exp_let of rec_flag * value_binding list * expression - (** [Exp_let(flag, [(P1,E1) ; ... ; (Pn,En)], E)] represents: - - [let P1 = E1 and ... and Pn = EN in E] when [flag] is [Nonrecursive] - - [let rec P1 = E1 and ... and Pn = EN in E] when [flag] is [Recursive] - *) - | Exp_function of pattern list * function_body - (** [Exp_function ([P1; ...; Pn], body)] represents any construct - involving [fun] or [function], including: - - [fun P1 ... Pn -> E] - when [body = Function_body E] - - [fun P1 ... Pn -> function p1 -> e1 | ... | pm -> em] - when [body = Function_cases [ p1 -> e1; ...; pm -> em ]] - - A function must have parameters. [Exp_function (params, body)] must - have non-empty [params] or a [Function_cases _] body. - *) - | Exp_apply of expression * expression - (** [Exp_apply(E0, E1)] represents [E0 E1] *) - | Exp_match of expression * case list - (** [match E0 with P1 -> E1 | ... | Pn -> En] *) - | Exp_tuple of expression list - (** Expressions [(E1, ..., En)]. Invariant: [n >= 2] *) - | Exp_construct of ident * expression option - (** [Exp_construct(C, exp)] represents: - - [C] when [exp] is [None], - - [C E] when [exp] is [Some E], - - [C (E1, ..., En)] when [exp] is [Some (Exp_tuple[E1;...;En])] - *) - | Exp_ifthenelse of expression * expression * expression option - (** [if E1 then E2 else E3] *) - | Exp_sequence of expression * expression (** [E1; E2] *) -[@@deriving show {with_path= false}] - -(* ======= Module structure ======= *) - -type structure = structure_item list [@@deriving show {with_path= false}] - -and structure_item = - | Str_eval of expression (** [E] *) - | Str_value of rec_flag * value_binding list - (** [Str_value(rec, [(P1, E1) ; ... ; (Pn, En)])] represents: - - [let P1 = E1 and ... and Pn = EN] - when [rec] is [Nonrecursive] - - [let rec P1 = E1 and ... and Pn = EN ] - when [rec] is [Recursive] - *) -[@@deriving show {with_path= false}] diff --git a/OCamlTyEff/lib/ast/dune b/OCamlTyEff/lib/ast/dune deleted file mode 100644 index 87fd87a5f..000000000 --- a/OCamlTyEff/lib/ast/dune +++ /dev/null @@ -1,5 +0,0 @@ -(library - (name ast) - (public_name OCamlTyEff.Ast) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq))) diff --git a/OCamlTyEff/lib/parser/common.ml b/OCamlTyEff/lib/parser/common.ml deleted file mode 100644 index 4a003ea1c..000000000 --- a/OCamlTyEff/lib/parser/common.ml +++ /dev/null @@ -1,282 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast - -let pp printer parser str = - Stdlib.Format.printf "%a" printer - @@ Result.ok_or_failwith - @@ Angstrom.parse_string ~consume:Angstrom.Consume.All parser str - -let skip_whitespaces = skip_while Char.is_whitespace - -let skip_whitespaces1 = take_while1 Char.is_whitespace *> return () - -let parse_comments = - skip_whitespaces *> string "(*" - *> many_till any_char (string "*)") - *> return () - -let ws = many parse_comments *> skip_whitespaces - -let ws1 = - (skip_whitespaces1 *> many parse_comments <|> many1 parse_comments) - *> return () - -(* ======= Operator names ======= *) - -let is_core_operator_char = function - | '$' | '&' | '*' | '+' | '-' | '/' | '=' | '>' | '@' | '^' | '|' -> - true - | _ -> - false - -let is_operator_char = function - | '~' | '!' | '?' | '%' | '<' | ':' | '.' -> - true - | _ as x when is_core_operator_char x -> - true - | _ -> - false - -let parse_custom_prefix_operator_name = - let parse_prefix1 = - (* ! { operator-char } *) - char '!' *> take_while is_operator_char >>| fun s -> "!" ^ s - in - let parse_prefix2 = - (* (?|~) { operator-char }+ *) - let parse_first = - satisfy (fun c -> Char.equal '?' c || Char.equal '~' c) >>| String.of_char - in - let parse_rest = take_while1 is_operator_char in - lift2 String.( ^ ) parse_first parse_rest - in - parse_prefix1 <|> parse_prefix2 - -let peek_custom_infix_operator_name = - (* (core-operator-char | % | <) { operator-char } *) - let peek_first = - peek_char_fail - >>= fun c -> - if is_core_operator_char c || Char.equal c '%' || Char.equal c '<' then - return (String.of_char c) - else fail "not a infix-symbol" - in - let rec peek_rest acc index = - peek_string index - >>| (fun s -> String.get s (String.length s - 1)) (* get last char *) - >>= fun c -> - if is_operator_char c then peek_rest (acc ^ String.of_char c) (index + 1) - else return acc - in - lift2 String.( ^ ) peek_first (peek_rest "" 2) - -let parse_custom_operator_name = - parse_custom_prefix_operator_name - <|> ( peek_custom_infix_operator_name - >>= fun name -> advance (String.length name) *> return name ) - -(* ======= Value names ======= *) - -let is_keyword = function - | "and" - | "as" - | "assert" - | "asr" - | "begin" - | "class" - | "constraint" - | "do" - | "done" - | "downto" - | "else" - | "end" - | "exception" - | "external" - | "false" - | "for" - | "fun" - | "function" - | "functor" - | "if" - | "in" - | "include" - | "inherit" - | "initializer" - | "land" - | "lazy" - | "let" - | "lor" - | "lsl" - | "lsr" - | "lxor" - | "match" - | "method" - | "mod" - | "module" - | "mutable" - | "new" - | "nonrec" - | "object" - | "of" - | "open" - | "or" - | "private" - | "rec" - | "sig" - | "struct" - | "then" - | "to" - | "true" - | "try" - | "type" - | "val" - | "virtual" - | "when" - | "while" - | "with" -> - true - | _ -> - false - -let parse_lowercase_ident = - let parse_first = - satisfy (function 'a' .. 'z' | '_' -> true | _ -> false) - >>| String.of_char - in - let parse_rest = - take_while (function - | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '\'' -> - true - | _ -> - false ) - in - lift2 String.( ^ ) parse_first parse_rest - -let parse_uppercase_ident = - let parse_first = - satisfy (function 'A' .. 'Z' -> true | _ -> false) >>| String.of_char - in - let parse_rest = - take_while (function - | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '\'' -> - true - | _ -> - false ) - in - lift2 String.( ^ ) parse_first parse_rest - -let parse_value_name = - parse_lowercase_ident - <|> (char '(' *> ws *> parse_custom_operator_name <* ws <* char ')') - >>= fun name -> - if not (is_keyword name) then return name - else fail (name ^ " keyword can't be used as value name") - -let parse_constr_name = parse_uppercase_ident - -(* ======= Constants ======= *) - -let parse_int = - take_while1 (function '0' .. '9' -> true | _ -> false) - >>| fun i -> Const_integer (Int.of_string i) - -(** ["hello world"] *) -let parse_string = - let open Char in - char (of_int_exn 34) *> take_till (Char.equal (of_int_exn 34)) - <* char (of_int_exn 34) (* [of_int_exn 34 = '"'] *) - >>| fun s -> Const_string s - -let parse_char = char '\'' *> any_char <* char '\'' >>| fun c -> Const_char c - -let parse_const = choice [parse_char; parse_string; parse_int] - -(* ======= Value bindings ======= *) - -let skip_let_keyword = ws *> string "let" - -let parse_rec_flag = - ws1 *> option Nonrecursive (string "rec" *> return Recursive) - -(** - [P1 = E1 and ... and Pn = En] - [P1 PArg1 = E1 and ... and Pn = En] -*) -let parse_bindings pexp ppat = - let parse_binding = - let parse_args = ws *> sep_by ws ppat in - let insert_args exp = function - (* [let f x = E] => [let f = fun x -> E] *) - | [] -> - exp - | _ as args -> - Exp_function (args, Function_body exp) - in - lift3 - (fun pat args exp -> {pat; expr= insert_args exp args}) - ppat parse_args - (ws *> char '=' *> pexp) - in - sep_by1 (ws *> string "and") parse_binding - -let parse_let_binding pexp ppat = - skip_let_keyword *> both parse_rec_flag (parse_bindings pexp ppat) - -(* ======= Infix & prefix parsing ======= *) - -type 'a infix_operator = {op: 'a; op_length: int} - -let parse_infix_prefix ~parse_operand ~peek_infix_op ~get_infix_binding_power - ~infix_fold_fun ~parse_prefix_op ~get_prefix_binding_power ~apply_prefix_op - = - (* - Pratt parsing - https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html - *) - let rec helper min_bp = - let* lhs = - option None (ws *> parse_prefix_op >>| Option.some) - >>= function - | None -> - parse_operand - | Some op -> - let r_bp = get_prefix_binding_power op in - let* rhs = helper r_bp in - return (apply_prefix_op op rhs) - in - many - (let* {op; op_length} = ws *> peek_infix_op in - let l_bp, r_bp = get_infix_binding_power op in - if l_bp < min_bp then fail "found op with lower binding power" - else - advance op_length - *> let* rhs = helper r_bp in - return (op, rhs) ) - >>| fun results -> List.fold_left ~init:lhs ~f:infix_fold_fun results - in - helper 0 - -let%expect_test "parse_custom_operator_name1" = - pp Format.pp_print_string parse_value_name "(>>)" ; - [%expect {| >> |}] - -let%expect_test "parse_custom_operator_name2" = - pp Format.pp_print_string parse_value_name "(%>)" ; - [%expect {| %> |}] - -let%expect_test "parse_custom_operator_name3" = - pp Format.pp_print_string parse_value_name "(!)" ; - [%expect {| ! |}] - -let%expect_test "parse_custom_operator_name4" = - pp Format.pp_print_string parse_value_name "(~:=)" ; - [%expect {| ~:= |}] - -let%expect_test "parse_custom_operator_name5" = - pp Format.pp_print_string parse_value_name "(@<>)" ; - [%expect {| @<> |}] diff --git a/OCamlTyEff/lib/parser/common.mli b/OCamlTyEff/lib/parser/common.mli deleted file mode 100644 index ddfe9ff92..000000000 --- a/OCamlTyEff/lib/parser/common.mli +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast - -val pp : (Format.formatter -> 'a -> unit) -> 'a t -> string -> unit -(** - Run parser on string and pretty print the output using printer. - Used for inline expect tests -*) - -val ws : unit t -(** skip whitespaces *) - -val is_core_operator_char : char -> bool -(** core-operator-char ::= \{$ | & | * | + | - | / | = | > | @ | ^ | \| \} *) - -val is_operator_char : char -> bool -(** operator-char ::= \{~ | ! | ? | core-operator-char | % | < | : | .\} *) - -val peek_custom_infix_operator_name : string t -(** - infix-symbol ::= (core-operator-char | % | <) \{ operator-char \} -*) - -val parse_custom_prefix_operator_name : string t -(** - prefix-symbol ::= ! \{ operator-char \} - | (? | ~) \{ operator-char \}+ -*) - -val parse_value_name : string t -(** - value-name ::= (a..z | _) \{ A..Z | a..z | 0..9 | _ | ' \} - | (prefix-symbol ∣ infix-symbol) - must not be keyword -*) - -val parse_constr_name : string t -(** constr-name ::= (A..Z) \{ A..Z | a..z | 0..9 | _ | ' \} *) - -val parse_const : constant t - -val parse_let_binding : - expression t -> pattern t -> (rec_flag * value_binding list) t -(** - [let P1 = E1 and P2 = E2 and ... and Pn = En] - [let rec P1 PArg1 = E1 and P2 = E2 and ... and Pn = En] -*) - -type 'a infix_operator = {op: 'a; op_length: int} - -val parse_infix_prefix : - parse_operand:'exp t - -> peek_infix_op:'infix infix_operator t - -> get_infix_binding_power:('infix -> int * int) - -> infix_fold_fun:('exp -> 'infix * 'exp -> 'exp) - -> parse_prefix_op:'prefix t - -> get_prefix_binding_power:('prefix -> int) - -> apply_prefix_op:('prefix -> 'exp -> 'exp) - -> 'exp t -(** Parse expressions with infix and prefix operators using Pratt parsing *) diff --git a/OCamlTyEff/lib/parser/dune b/OCamlTyEff/lib/parser/dune deleted file mode 100644 index c1a8bf382..000000000 --- a/OCamlTyEff/lib/parser/dune +++ /dev/null @@ -1,18 +0,0 @@ -(library - (name parser) - (public_name OCamlTyEff.Parser) - (modules common expr pattern structure parser) - (libraries base angstrom ast) - (preprocess - (pps ppx_expect ppx_deriving.eq)) - (inline_tests) - (instrumentation - (backend bisect_ppx))) - -(library - (name test) - (modules test) - (libraries base ast parser) - (preprocess - (pps ppx_expect)) - (inline_tests)) diff --git a/OCamlTyEff/lib/parser/expr.ml b/OCamlTyEff/lib/parser/expr.ml deleted file mode 100644 index 4f70f090c..000000000 --- a/OCamlTyEff/lib/parser/expr.ml +++ /dev/null @@ -1,451 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast -open Common -open Pattern - -(* ======= Single expressions parsing ======= *) - -let parse_exp_ident = parse_value_name >>| fun name -> Exp_ident (Ident name) - -let parse_exp_const = parse_const >>| fun const -> Exp_constant const - -let parse_exp_constr = - parse_constr_name >>| fun name -> Exp_construct (Ident name, None) - -(** - [let P1 = E1 and P2 = E2 and ... and Pn = En in E] - [let rec P1 PArg1 = E1 and P2 = E2 and ... and Pn = En in E] -*) -let parse_exp_let pexp = - lift2 - (fun (rec_flag, bindings) exp -> Exp_let (rec_flag, bindings, exp)) - (parse_let_binding pexp parse_pattern) - (ws *> string "in" *> pexp) - -(** [if E1 then E2 else E3 ] *) -let parse_exp_ite pexp_if pexp_thenelse = - lift3 - (fun c t e -> Exp_ifthenelse (c, t, e)) - (string "if" *> pexp_if) - (ws *> string "then" *> pexp_thenelse) - (* None if else not found *) - ( option None (ws *> string "else" >>| Option.some) - >>= function None -> return None | Some _ -> pexp_thenelse >>| Option.some - ) - -(** [a; b; c] *) -let parse_exp_list pexp = - let parse_list = - sep_by (ws *> char ';') pexp - >>| fun list -> - let rec helper = function - | h :: tl -> - Exp_construct (Ident "::", Some (Exp_tuple [h; helper tl])) - | [] -> - Exp_construct (Ident "[]", None) - in - helper list - in - char '[' *> parse_list <* ws <* char ']' - -let parse_match_cases pexp = - let parse_case = - lift2 - (fun pat exp -> {left= pat; right= exp}) - (parse_pattern <* ws <* string "->" <* ws) - pexp - in - option () (char '|' *> return ()) (* skip | if there *) - *> sep_by1 (ws *> char '|' *> ws) parse_case - -let parse_exp_match pexp_match pexp_with = - lift2 - (fun exp cases -> Exp_match (exp, cases)) - (string "match" *> pexp_match) - (ws *> string "with" *> ws *> parse_match_cases pexp_with) - -(* ======= Operators parsing ======= *) - -type expr_infix_op = - | IOpSeq - | IOpList - | IOpTuple - | IOpApply - | IOpCustom of ident -[@@deriving eq] - -(** - Try to peek infix operator. If nothing found return IOpApply. - Fail if [disabled_op] found -*) -let peek_infix_op disabled_op = - let peek_list_operator = - peek_string 2 - >>= fun s -> - if String.equal s "::" then return {op= IOpList; op_length= 2} - else fail "not a list operator" - in - let peek_seq_operator = - peek_char_fail - >>= fun c -> - if Char.equal c ';' then return {op= IOpSeq; op_length= 1} - else fail "not a seq operator" - in - let peek_tuple_operator = - peek_char_fail - >>= fun c -> - if Char.equal c ',' then return {op= IOpTuple; op_length= 1} - else fail "not a tuple operator" - in - let peek_custom_infix_op = - peek_custom_infix_operator_name - >>| fun name -> {op= IOpCustom (Ident name); op_length= String.length name} - in - option - {op= IOpApply; op_length= 0} (* application operator is 0 chars long *) - ( choice - [ peek_custom_infix_op - ; peek_list_operator - ; peek_seq_operator - ; peek_tuple_operator ] - >>= fun op -> - (* fail if disabled_op was passed and found *) - Option.value_map disabled_op ~default:(return op) ~f:(fun disabled_op -> - if equal_expr_infix_op disabled_op op.op then fail "operator disabled" - else return op ) ) - -(** - Set precedence and associativity for operators. - https://v2.ocaml.org/manual/expr.html#ss:precedence-and-associativity - - Used in Pratt parsing method -*) -let get_infix_binding_power = function - | IOpApply -> - (100, 101) - | IOpList -> - (81, 80) - | IOpSeq -> - (11, 10) - | IOpTuple -> - (51, 50) - | IOpCustom (Ident id) -> - let is_prefix prefix = String.is_prefix ~prefix id in - let is_equal str = String.( = ) id str in - if is_prefix "**" then (91, 90) - else if is_prefix "*" || is_prefix "/" || is_prefix "%" then (85, 86) - else if is_prefix "+" || is_prefix "-" then (83, 84) - else if is_prefix "@" || is_prefix "^" then (79, 78) - else if - is_prefix "=" || is_prefix "<" || is_prefix ">" || is_prefix "|" - || (is_prefix "&" && not (is_equal "&")) - || is_prefix "$" || is_equal "!=" - then (75, 76) - else if is_equal "&" || is_equal "&&" then (71, 70) - else if is_equal "||" then (66, 65) - else assert false - -type expr_prefix_op = POpPlus | POpMinus | POpCustom of ident - -let parse_prefix_op = - let parse_prefix_plus = char '+' *> return POpPlus in - let parse_prefix_minus = char '-' *> return POpMinus in - let parse_custom_prefix_op = - parse_custom_prefix_operator_name >>| fun id -> POpCustom (Ident id) - in - choice [parse_prefix_minus; parse_prefix_plus; parse_custom_prefix_op] - -let get_prefix_binding_power = function - | POpPlus | POpCustom _ -> - 500 (* highest precedence *) - | POpMinus -> - 95 (* a bit lower than application precedence *) - -let parse_expression = - let parse_single_exp pexp = - ws - *> choice - [ parse_exp_ident - ; parse_exp_const - ; parse_exp_constr - ; char '(' *> pexp None <* ws <* char ')' - (* disable ; as it's a separator in lists *) - ; parse_exp_list (pexp (Some IOpSeq)) - ; parse_exp_let (pexp None) - (* disable ; in [then] and [else] blocks to maintain correct precedence *) - ; parse_exp_ite (pexp None) (pexp (Some IOpSeq)) - (* disable | in [with] block as it's used as cases separator *) - ; parse_exp_match (pexp None) (pexp (Some (IOpCustom (Ident "|")))) ] - in - let rec parse_ops disabled_op = - let infix_fold_fun acc (op, rhs) = - match op with - | IOpApply -> ( - match acc with - | Exp_construct (id, None) -> - (* constructor application *) - Exp_construct (id, Some rhs) - | _ -> - (* function application *) - Exp_apply (acc, rhs) ) - | IOpList -> - Exp_construct (Ident "::", Some (Exp_tuple [acc; rhs])) - | IOpSeq -> - Exp_sequence (acc, rhs) - | IOpTuple -> ( - match rhs with - | Exp_tuple l -> - Exp_tuple (acc :: l) - | _ -> - Exp_tuple [acc; rhs] ) - | IOpCustom op -> - Exp_apply (Exp_apply (Exp_ident op, acc), rhs) - in - let apply_prefix_op op exp = - Exp_apply - ( Exp_ident - ( match op with - | POpMinus -> - Ident "~-" - | POpPlus -> - Ident "~+" - | POpCustom id -> - id ) - , exp ) - in - fix (fun _ -> - parse_infix_prefix - ~parse_operand:(parse_single_exp parse_ops) - ~peek_infix_op:(peek_infix_op disabled_op) - ~get_infix_binding_power ~infix_fold_fun ~parse_prefix_op - ~get_prefix_binding_power ~apply_prefix_op ) - in - parse_ops None - -(* ======= Tests ======= *) - -let%expect_test "parse_custom_operator1" = - pp pp_expression parse_expression "a >>= b ++ c ** d !+ e" ; - [%expect - {| - (Exp_apply ((Exp_apply ((Exp_ident (Ident ">>=")), (Exp_ident (Ident "a")))), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "++")), (Exp_ident (Ident "b")))), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "**")), (Exp_ident (Ident "c")))), - (Exp_apply ((Exp_ident (Ident "d")), - (Exp_apply ((Exp_ident (Ident "!+")), (Exp_ident (Ident "e")))))) - )) - )) - )) |}] - -let%expect_test "parse_let" = - pp pp_expression - (parse_exp_let parse_expression) - "let rec a = 1 and b = 2 in let e = 3 in a" ; - [%expect - {| - (Exp_let (Recursive, - [{ pat = (Pat_var "a"); expr = (Exp_constant (Const_integer 1)) }; - { pat = (Pat_var "b"); expr = (Exp_constant (Const_integer 2)) }], - (Exp_let (Nonrecursive, - [{ pat = (Pat_var "e"); expr = (Exp_constant (Const_integer 3)) }], - (Exp_ident (Ident "a")))) - )) |}] - -let%expect_test "parse_ifthenelse" = - pp pp_expression parse_expression "if a then (if b then c) else d" ; - [%expect - {| - (Exp_ifthenelse ((Exp_ident (Ident "a")), - (Exp_ifthenelse ((Exp_ident (Ident "b")), (Exp_ident (Ident "c")), None)), - (Some (Exp_ident (Ident "d"))))) |}] - -let%expect_test "parse_if_with_seq1" = - pp pp_expression parse_expression "if a; b then c; d" ; - [%expect - {| - (Exp_sequence ( - (Exp_ifthenelse ( - (Exp_sequence ((Exp_ident (Ident "a")), (Exp_ident (Ident "b")))), - (Exp_ident (Ident "c")), None)), - (Exp_ident (Ident "d")))) |}] - -let%expect_test "parse_if_with_seq2" = - pp pp_expression parse_expression "if a; b then (c; d)" ; - [%expect - {| - (Exp_ifthenelse ( - (Exp_sequence ((Exp_ident (Ident "a")), (Exp_ident (Ident "b")))), - (Exp_sequence ((Exp_ident (Ident "c")), (Exp_ident (Ident "d")))), None)) |}] - -let%expect_test "parse_match1" = - pp pp_expression parse_expression "match a with b -> c | d -> e" ; - [%expect - {| - (Exp_match ((Exp_ident (Ident "a")), - [{ left = (Pat_var "b"); right = (Exp_ident (Ident "c")) }; - { left = (Pat_var "d"); right = (Exp_ident (Ident "e")) }] - )) |}] - -let%expect_test "parse_match2" = - pp pp_expression parse_expression "match a with | b | c | d -> e | f -> g" ; - [%expect - {| - (Exp_match ((Exp_ident (Ident "a")), - [{ left = - (Pat_or ((Pat_or ((Pat_var "b"), (Pat_var "c"))), (Pat_var "d"))); - right = (Exp_ident (Ident "e")) }; - { left = (Pat_var "f"); right = (Exp_ident (Ident "g")) }] - )) |}] - -let%expect_test "parse_constr1" = - pp pp_expression parse_expression "Nil" ; - [%expect {| (Exp_construct ((Ident "Nil"), None)) |}] - -let%expect_test "parse_constr2" = - pp pp_expression parse_expression "Some x" ; - [%expect - {| (Exp_construct ((Ident "Some"), (Some (Exp_ident (Ident "x"))))) |}] - -let%expect_test "parse_constr3" = - pp pp_expression parse_expression "Cons (1, Nil)" ; - [%expect - {| - (Exp_construct ((Ident "Cons"), - (Some (Exp_tuple - [(Exp_constant (Const_integer 1)); - (Exp_construct ((Ident "Nil"), None))])) - )) |}] - -let%expect_test "parse_list" = - pp pp_expression parse_expression "[a;b;c]" ; - [%expect - {| - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "a")); - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "b")); - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "c")); - (Exp_construct ((Ident "[]"), None - )) - ])) - )) - ])) - )) - ])) - )) |}] - -let%expect_test "parse_list_with_seq" = - pp pp_expression parse_expression "[a;(b;c)]" ; - [%expect - {| - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "a")); - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_sequence ((Exp_ident (Ident "b")), - (Exp_ident (Ident "c")))); - (Exp_construct ((Ident "[]"), None))])) - )) - ])) - )) |}] - -let%expect_test "parse_list_1element" = - pp pp_expression parse_expression "[a]" ; - [%expect - {| - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "a")); (Exp_construct ((Ident "[]"), None))])) - )) |}] - -let%expect_test "parse_list_empty" = - pp pp_expression parse_expression "[]" ; - [%expect {| (Exp_construct ((Ident "[]"), None)) |}] - -let%expect_test "parse_list_op" = - pp pp_expression parse_expression "(a :: b) :: c :: d :: []" ; - [%expect - {| - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "a")); (Exp_ident (Ident "b"))])) - )); - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "c")); - (Exp_construct ((Ident "::"), - (Some (Exp_tuple - [(Exp_ident (Ident "d")); - (Exp_construct ((Ident "[]"), None - )) - ])) - )) - ])) - )) - ])) - )) |}] - -let%expect_test "parse_seq_op" = - pp pp_expression parse_expression "(a ; b) ; c ; d ; e" ; - [%expect - {| - (Exp_sequence ( - (Exp_sequence ((Exp_ident (Ident "a")), (Exp_ident (Ident "b")))), - (Exp_sequence ((Exp_ident (Ident "c")), - (Exp_sequence ((Exp_ident (Ident "d")), (Exp_ident (Ident "e")))))) - )) |}] - -let%expect_test "parse_tuple_op" = - pp pp_expression parse_expression "a, (b, c), d, e" ; - [%expect - {| - (Exp_tuple - [(Exp_ident (Ident "a")); - (Exp_tuple [(Exp_ident (Ident "b")); (Exp_ident (Ident "c"))]); - (Exp_ident (Ident "d")); (Exp_ident (Ident "e"))]) |}] - -let%expect_test "parse_plus_minus_prefix_op" = - pp pp_expression parse_expression "1 + - + + 3" ; - [%expect - {| - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "+")), (Exp_constant (Const_integer 1)))), - (Exp_apply ((Exp_ident (Ident "~-")), - (Exp_apply ((Exp_ident (Ident "~+")), - (Exp_apply ((Exp_ident (Ident "~+")), - (Exp_constant (Const_integer 3)))) - )) - )) - )) |}] - -let%expect_test "parse_custom_prefix_op" = - pp pp_expression parse_expression "?!5; !%< 123; !0; ~-3" ; - [%expect - {| - (Exp_sequence ( - (Exp_apply ((Exp_ident (Ident "?!")), (Exp_constant (Const_integer 5)))), - (Exp_sequence ( - (Exp_apply ((Exp_ident (Ident "!%<")), - (Exp_constant (Const_integer 123)))), - (Exp_sequence ( - (Exp_apply ((Exp_ident (Ident "!")), - (Exp_constant (Const_integer 0)))), - (Exp_apply ((Exp_ident (Ident "~-")), - (Exp_constant (Const_integer 3)))) - )) - )) - )) |}] diff --git a/OCamlTyEff/lib/parser/expr.mli b/OCamlTyEff/lib/parser/expr.mli deleted file mode 100644 index 88176606d..000000000 --- a/OCamlTyEff/lib/parser/expr.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast - -val parse_expression : expression t diff --git a/OCamlTyEff/lib/parser/parser.ml b/OCamlTyEff/lib/parser/parser.ml deleted file mode 100644 index cf1c868d3..000000000 --- a/OCamlTyEff/lib/parser/parser.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base - -let parse str = - Angstrom.parse_string ~consume:Angstrom.Consume.All Structure.parse_structure - str - -let parse_exn str = Result.ok_or_failwith (parse str) diff --git a/OCamlTyEff/lib/parser/parser.mli b/OCamlTyEff/lib/parser/parser.mli deleted file mode 100644 index 235aa3260..000000000 --- a/OCamlTyEff/lib/parser/parser.mli +++ /dev/null @@ -1,10 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base - -val parse : string -> (Ast.structure, string) result - -val parse_exn : string -> Ast.structure -(** Raises [Failure] exception if parsing fails *) diff --git a/OCamlTyEff/lib/parser/pattern.ml b/OCamlTyEff/lib/parser/pattern.ml deleted file mode 100644 index dcde6d81f..000000000 --- a/OCamlTyEff/lib/parser/pattern.ml +++ /dev/null @@ -1,174 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast -open Common - -(* ======= Single patterns parsing ======= *) - -let parse_pat_any = char '_' *> return Pat_any - -let parse_pat_var = parse_value_name >>| fun name -> Pat_var name - -let parse_pat_const = parse_const >>| fun const -> Pat_constant const - -(* [Cons (hd, tl)] *) -let parse_pat_constr ppat_single = - let* name = parse_constr_name in - let* arg = option None (ppat_single <* ws >>| Option.some) in - return (Pat_construct (Ident name, arg)) - -let parse_single_pat ppat = - fix (fun ppat_single -> - ws - *> choice - [ parse_pat_any - ; parse_pat_var - ; parse_pat_const - ; parse_pat_constr ppat_single - ; char '(' *> ppat <* ws <* char ')' ] ) - -(* ======= Operators parsing ======= *) - -type pat_infix_op = OpOr | OpTuple | OpList - -let peek_infix_op = - let peek_tuple_or_ops = - peek_char_fail - >>= function - | '|' -> - return {op= OpOr; op_length= 1} - | ',' -> - return {op= OpTuple; op_length= 1} - | _ -> - fail "not a pattern infix operator" - in - let peek_list_op = - peek_string 2 - >>= fun s -> - if String.equal s "::" then return {op= OpList; op_length= 2} - else fail "not a pattern list operator" - in - peek_tuple_or_ops <|> peek_list_op - -let get_infix_binding_power = function - | OpOr -> - (1, 2) - | OpTuple -> - (5, 4) - | OpList -> - (11, 10) - -let parse_pattern = - let infix_fold_fun acc (op, rhs) = - match op with - | OpOr -> - Pat_or (acc, rhs) - | OpTuple -> ( - match rhs with - | Pat_tuple tl -> - Pat_tuple (acc :: tl) - | _ -> - Pat_tuple [acc; rhs] ) - | OpList -> - Pat_construct (Ident "::", Some (Pat_tuple [acc; rhs])) - in - fix (fun ppat -> - parse_infix_prefix ~parse_operand:(parse_single_pat ppat) ~peek_infix_op - ~get_infix_binding_power ~infix_fold_fun - ~parse_prefix_op:(fail "no prefix ops in patterns") - ~get_prefix_binding_power:(fun _ -> assert false) - ~apply_prefix_op:(fun _ -> assert false) ) - -(* ======= Tests ======= *) - -let%expect_test "parse_pat_var" = - pp pp_pattern parse_pattern "a" ; - [%expect {| (Pat_var "a") |}] - -let%expect_test "parse_pat_any" = - pp pp_pattern parse_pattern "_" ; - [%expect {| Pat_any |}] - -let%expect_test "parse_pat_const" = - pp pp_pattern parse_pattern "5" ; - [%expect {| (Pat_constant (Const_integer 5)) |}] - -let%expect_test "parse_pat_constr1" = - pp pp_pattern parse_pattern "C" ; - [%expect {| (Pat_construct ((Ident "C"), None)) |}] - -let%expect_test "parse_pat_constr2" = - pp pp_pattern parse_pattern "C a" ; - [%expect {| (Pat_construct ((Ident "C"), (Some (Pat_var "a")))) |}] - -let%expect_test "parse_pat_constr2" = - pp pp_pattern parse_pattern "Cons (hd, tl)" ; - [%expect - {| - (Pat_construct ((Ident "Cons"), - (Some (Pat_tuple [(Pat_var "hd"); (Pat_var "tl")])))) |}] - -let%expect_test "parse_pat_constr_or_tuple" = - pp pp_pattern parse_pattern "C _ | a, b" ; - [%expect - {| - (Pat_or ((Pat_construct ((Ident "C"), (Some Pat_any))), - (Pat_tuple [(Pat_var "a"); (Pat_var "b")]))) |}] - -let%expect_test "parse_pat_or" = - pp pp_pattern parse_pattern "a | (b | c) | d" ; - [%expect - {| - (Pat_or ((Pat_or ((Pat_var "a"), (Pat_or ((Pat_var "b"), (Pat_var "c"))))), - (Pat_var "d"))) |}] - -let%expect_test "parse_pat_tuple" = - pp pp_pattern parse_pattern "a, (b, c), d" ; - [%expect - {| - (Pat_tuple - [(Pat_var "a"); (Pat_tuple [(Pat_var "b"); (Pat_var "c")]); (Pat_var "d")]) |}] - -let%expect_test "parse_pat_or_tuple" = - pp pp_pattern parse_pattern "a, b | c, d" ; - [%expect - {| - (Pat_or ((Pat_tuple [(Pat_var "a"); (Pat_var "b")]), - (Pat_tuple [(Pat_var "c"); (Pat_var "d")]))) |}] - -let%expect_test "parse_pat_list" = - pp pp_pattern parse_pattern "a::(b::c)::d" ; - [%expect - {| - (Pat_construct ((Ident "::"), - (Some (Pat_tuple - [(Pat_var "a"); - (Pat_construct ((Ident "::"), - (Some (Pat_tuple - [(Pat_construct ((Ident "::"), - (Some (Pat_tuple [(Pat_var "b"); (Pat_var "c")])) - )); - (Pat_var "d")])) - )) - ])) - )) |}] - -let%expect_test "parse_pat_list_or_tuple" = - pp pp_pattern parse_pattern "a::b::c,d|e" ; - [%expect - {| - (Pat_or ( - (Pat_tuple - [(Pat_construct ((Ident "::"), - (Some (Pat_tuple - [(Pat_var "a"); - (Pat_construct ((Ident "::"), - (Some (Pat_tuple [(Pat_var "b"); (Pat_var "c")])))) - ])) - )); - (Pat_var "d")]), - (Pat_var "e"))) |}] diff --git a/OCamlTyEff/lib/parser/pattern.mli b/OCamlTyEff/lib/parser/pattern.mli deleted file mode 100644 index 619cdc4bb..000000000 --- a/OCamlTyEff/lib/parser/pattern.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast - -val parse_pattern : pattern t diff --git a/OCamlTyEff/lib/parser/structure.ml b/OCamlTyEff/lib/parser/structure.ml deleted file mode 100644 index 04bcb3ee1..000000000 --- a/OCamlTyEff/lib/parser/structure.ml +++ /dev/null @@ -1,24 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast -open Common -open Expr -open Pattern - -(** - [let P1 = E1 and P2 = E2 and ... and Pn = En] - [let rec P1 PArg1 = E1 and P2 = E2 and ... and Pn = En] -*) -let parse_str_let = - parse_let_binding parse_expression parse_pattern - >>| fun (rec_flag, bindings) -> Str_value (rec_flag, bindings) - -let parse_structure : structure t = - let parse_structure_item = - parse_str_let <|> (parse_expression >>| fun e -> Str_eval e) - in - sep_by ws parse_structure_item <* ws diff --git a/OCamlTyEff/lib/parser/structure.mli b/OCamlTyEff/lib/parser/structure.mli deleted file mode 100644 index d6c40936d..000000000 --- a/OCamlTyEff/lib/parser/structure.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Angstrom -open Ast - -val parse_structure : structure t diff --git a/OCamlTyEff/lib/parser/test.ml b/OCamlTyEff/lib/parser/test.ml deleted file mode 100644 index 1792f8670..000000000 --- a/OCamlTyEff/lib/parser/test.ml +++ /dev/null @@ -1,118 +0,0 @@ -(** Copyright 2023 Danil S, Andrei *) - -(** SPDX-License-Identifier: MIT *) - -open! Base -open Ast - -(** Parse string and pretty print the output *) -let pp str = Stdlib.Format.printf "%a" pp_structure (Parser.parse_exn str) - -let%expect_test "parse_custom_operator1" = - pp "let (>>=) a b = a ** b" ; - [%expect - {| - [(Str_value (Nonrecursive, - [{ pat = (Pat_var ">>="); - expr = - (Exp_function ([(Pat_var "a"); (Pat_var "b")], - (Function_body - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "**")), (Exp_ident (Ident "a")) - )), - (Exp_ident (Ident "b"))))) - )) - } - ] - )) - ] |}] - -let%expect_test "parse_custom_operator2" = - pp "let (++) a b = a + b" ; - [%expect - {| - [(Str_value (Nonrecursive, - [{ pat = (Pat_var "++"); - expr = - (Exp_function ([(Pat_var "a"); (Pat_var "b")], - (Function_body - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "+")), (Exp_ident (Ident "a")) - )), - (Exp_ident (Ident "b"))))) - )) - } - ] - )) - ] |}] - -let%expect_test "parse_comments" = - pp - "let(*sas*)rec(*firstcomment*)f n = (* second comment *) (* third \ - comment*) n + 1" ; - [%expect - {| - [(Str_value (Recursive, - [{ pat = (Pat_var "f"); - expr = - (Exp_function ([(Pat_var "n")], - (Function_body - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "+")), (Exp_ident (Ident "n")) - )), - (Exp_constant (Const_integer 1))))) - )) - } - ] - )) - ] |}] - -let%expect_test "parse_let_rec_without_whitespaces" = - pp "letrec f n = n + 1" ; - [%expect - {| - [(Str_eval - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "=")), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "letrec")), - (Exp_ident (Ident "f")))), - (Exp_ident (Ident "n")))) - )), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "+")), (Exp_ident (Ident "n")))), - (Exp_constant (Const_integer 1)))) - ))) - ] |}] - -let%expect_test "parse_fact" = - pp "let rec fact n = if n < 2 then 1 else n * fact (n - 1)" ; - [%expect - {| - [(Str_value (Recursive, - [{ pat = (Pat_var "fact"); - expr = - (Exp_function ([(Pat_var "n")], - (Function_body - (Exp_ifthenelse ( - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "<")), - (Exp_ident (Ident "n")))), - (Exp_constant (Const_integer 2)))), - (Exp_constant (Const_integer 1)), - (Some (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "*")), - (Exp_ident (Ident "n")))), - (Exp_apply ((Exp_ident (Ident "fact")), - (Exp_apply ( - (Exp_apply ((Exp_ident (Ident "-")), - (Exp_ident (Ident "n")))), - (Exp_constant (Const_integer 1)))) - )) - ))) - ))) - )) - } - ] - )) - ] |}] diff --git a/OCamlWithEffects/.gitignore b/OCamlWithEffects/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/OCamlWithEffects/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/OCamlWithEffects/.ocamlformat b/OCamlWithEffects/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OCamlWithEffects/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OCamlWithEffects/COPYING b/OCamlWithEffects/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OCamlWithEffects/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OCamlWithEffects/COPYING.CC0 b/OCamlWithEffects/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OCamlWithEffects/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OCamlWithEffects/COPYING.LESSER b/OCamlWithEffects/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OCamlWithEffects/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OCamlWithEffects/DONT_REMOVE_THIS_DIRECTORY.md b/OCamlWithEffects/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/OCamlWithEffects/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/OCamlWithEffects/Makefile b/OCamlWithEffects/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OCamlWithEffects/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OCamlWithEffects/OCamlWithEffects.opam b/OCamlWithEffects/OCamlWithEffects.opam deleted file mode 100644 index 1817702f1..000000000 --- a/OCamlWithEffects/OCamlWithEffects.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "OCaml with effects" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Dmitry Pilyuk" "Rafik Nurmuhametov"] -authors: ["Dmitry Pilyuk" "Rafik Nurmuhametov"] -license: "LGPL-3.0-or-later" -homepage: - "https://github.com/DmitryPilyuk/fp2023/tree/master/OCamlWithEffects" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCamlWithEffects/README.md b/OCamlWithEffects/README.md deleted file mode 100644 index 61f7b1a9d..000000000 --- a/OCamlWithEffects/README.md +++ /dev/null @@ -1,12 +0,0 @@ -### An implementation of OCaml with effects - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Authors: [Dmitry Pilyuk](https://t.me/DmtrPlk), [Rafik Nurmuhametov](https://t.me/nrrafik) - -Features done (append only): - -Features in progress (and TODOs): - diff --git a/OCamlWithEffects/demos/demoFact.ml b/OCamlWithEffects/demos/demoFact.ml deleted file mode 100644 index 5cc217cc5..000000000 --- a/OCamlWithEffects/demos/demoFact.ml +++ /dev/null @@ -1,10 +0,0 @@ -open Ocaml_with_effects_lib -open Parser -open Ast - -let () = - let s = "let rec fact n = if n = 1 then 1 else n * fact (n - 1)" in - match parse s with - | Result.Ok ast -> Format.printf "%a\n" pp_program ast - | Error _ -> Format.printf "Error" -;; diff --git a/OCamlWithEffects/demos/demoFact.t b/OCamlWithEffects/demos/demoFact.t deleted file mode 100644 index af254b3c8..000000000 --- a/OCamlWithEffects/demos/demoFact.t +++ /dev/null @@ -1,12 +0,0 @@ - $ dune exec demoFact - [(EDeclaration ("fact", ["n"], - (EIfThenElse ( - (EBinaryOperation (Eq, (EIdentifier "n"), (EConst (Int 1)))), - (EConst (Int 1)), - (EBinaryOperation (Mul, (EIdentifier "n"), - (EApplication ((EIdentifier "fact"), - (EBinaryOperation (Sub, (EIdentifier "n"), (EConst (Int 1)))))) - )) - )) - )) - ] diff --git a/OCamlWithEffects/demos/dune b/OCamlWithEffects/demos/dune deleted file mode 100644 index 5139b9ba7..000000000 --- a/OCamlWithEffects/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demoFact) - (modules demoFact) - (public_name demoFact) - (libraries OCamlWithEffects.Lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demoFact})) diff --git a/OCamlWithEffects/dune b/OCamlWithEffects/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/OCamlWithEffects/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/OCamlWithEffects/dune-project b/OCamlWithEffects/dune-project deleted file mode 100644 index 0de340240..000000000 --- a/OCamlWithEffects/dune-project +++ /dev/null @@ -1,35 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Dmitry Pilyuk" "Rafik Nurmuhametov") - -(maintainers "Dmitry Pilyuk" "Rafik Nurmuhametov") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage - "https://github.com/DmitryPilyuk/fp2023/tree/master/OCamlWithEffects") - -(package - (name OCamlWithEffects) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "OCaml with effects") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/OCamlWithEffects/lib/ast.ml b/OCamlWithEffects/lib/ast.ml deleted file mode 100644 index 9d036b0bc..000000000 --- a/OCamlWithEffects/lib/ast.ml +++ /dev/null @@ -1,48 +0,0 @@ -(** Copyright 2021-2023, DmitryPilyuk and raf-nr *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type id = string [@@deriving eq, show { with_path = false }] - -type const = - | Char of char - | String of string - | Int of int - | Bool of bool - | Unit -[@@deriving eq, show { with_path = false }] - -type bin_op = - | Plus - | Sub - | Mul - | Div - | Eq - | NEq - | Gt - | Gte - | Lt - | Lte - | And - | Or -[@@deriving eq, show { with_path = false }] - -type un_op = - | Not - | Minus -[@@deriving eq, show { with_path = false }] - -type expr = - | EConst of const - | EBinaryOperation of bin_op * expr * expr - | EUnaryOperation of un_op * expr - | EIdentifier of id - | EApplication of expr * expr - | EFun of id list * expr - | EDeclaration of id * id list * expr - | ERecDeclaration of id * id list * expr - | EIfThenElse of expr * expr * expr - | EMatchWith of expr * (expr * expr) list -[@@deriving eq, show { with_path = false }] - -type program = expr list [@@deriving eq, show { with_path = false }] diff --git a/OCamlWithEffects/lib/dune b/OCamlWithEffects/lib/dune deleted file mode 100644 index ad972e554..000000000 --- a/OCamlWithEffects/lib/dune +++ /dev/null @@ -1,9 +0,0 @@ -(library - (name ocaml_with_effects_lib) - (public_name OCamlWithEffects.Lib) - (modules Parser Ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx))) diff --git a/OCamlWithEffects/lib/parser.ml b/OCamlWithEffects/lib/parser.ml deleted file mode 100644 index 3807d62d4..000000000 --- a/OCamlWithEffects/lib/parser.ml +++ /dev/null @@ -1,295 +0,0 @@ -(** Copyright 2021-2023, DmitryPilyuk and raf-nr *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Angstrom - -type dispatch = - { parse_bin_op : dispatch -> expr Angstrom.t - ; parse_application : dispatch -> expr Angstrom.t - ; parse_fun : dispatch -> expr Angstrom.t - ; parse_if_then_else : dispatch -> expr Angstrom.t - } - -(* Constructors for expressions *) -let econst x = EConst x -let ebinop op left_op right_op = EBinaryOperation (op, left_op, right_op) -let eunop operator operand = EUnaryOperation (operator, operand) -let identifier x = EIdentifier x -let eapplication f x = EApplication (f, x) -let efun var_list expression = EFun (var_list, expression) - -let declraration func_name var_list expression = - EDeclaration (func_name, var_list, expression) -;; - -let rec_declraration func_name var_list expression = - EDeclaration (func_name, var_list, expression) -;; - -let eif_then_else condition true_b false_b = EIfThenElse (condition, true_b, false_b) -let ematch_with expression cases = EMatchWith (expression, cases) -(* ---------------- *) - -(* Constructors for binary operations *) -let sAdd _ = Plus -let sSub _ = Sub -let sMul _ = Mul -let sDiv _ = Div -let sEq _ = Eq -let sNEq _ = NEq -let sGt _ = Gt -let sGte _ = Gte -let sLt _ = Lt -let sLte _ = Lte -let sAnd _ = And -let sOr _ = Or -(* ---------------- *) - -let is_keyword = function - | "let" | "rec" | "match" | "with" | "if" | "then" | "else" | "in" | "fun" | "and" -> - true - | _ -> false -;; - -let is_whitespace = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let skip_wspace = skip_while is_whitespace -let skip_wspace1 = take_while1 is_whitespace - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_upper = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_lower = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_ident c = is_lower c || is_upper c || c = '_' - -let is_acceptable_fl = function - | Some c when is_lower c || c = '_' -> return c - | _ -> fail "abc" -;; - -let is_letter c = is_upper c || is_lower c -let parens p = skip_wspace *> char '(' *> p <* skip_wspace <* char ')' - -let parse_name = - fix - @@ fun self -> - skip_wspace - *> (parens self - <|> take_while1 (fun x -> - is_lower x || is_upper x || is_digit x || x = '\'' || x = '_')) -;; - -let parse_uncapitalized_name = - parse_name - >>= fun name -> - if is_lower name.[0] || name.[0] = '_' - then return name - else fail "Parsing error: not an uncapitalized entity." -;; - -let parse_ident = - skip_wspace *> peek_char - >>= is_acceptable_fl - >>= fun _ -> - take_while is_ident - >>= fun s -> - if is_keyword s - then fail "Parsing error: name is used as keyword" - else return @@ EIdentifier s -;; - -let parse_const = - fix - @@ fun self -> - skip_wspace - *> (parens self - <|> - let parse_int = take_while1 is_digit >>| int_of_string >>| fun x -> Int x - and parse_str = - char '"' *> take_while (( != ) '"') <* char '"' >>| fun x -> String x - and parse_char = char '\'' *> any_char <* char '\'' >>| fun x -> Char x - and parse_bool = - string "true" <|> string "false" >>| bool_of_string >>| fun x -> Bool x - and parse_unit = string "()" >>| fun _ -> Unit in - let parse_const = - choice [ parse_int; parse_str; parse_char; parse_bool; parse_unit ] - in - lift econst parse_const) -;; - -let parse_fun pack = - fix - @@ fun self -> - skip_wspace - *> - let parse_expr = - choice - [ pack.parse_bin_op pack - ; pack.parse_application pack - ; self - ; pack.parse_if_then_else pack - ; parse_const - ; parse_ident - ] - in - parens self - <|> string "fun" - *> lift2 - efun - (many1 parse_uncapitalized_name <* skip_wspace <* string "->" <* skip_wspace) - (parse_expr <* skip_wspace) -;; - -let parse_if_then_else pack = - fix - @@ fun self -> - skip_wspace - *> - let parse_expr = - choice - [ pack.parse_bin_op pack - ; pack.parse_application pack - ; pack.parse_fun pack - ; self - ; parse_const - ; parse_ident - ] - in - parens self - <|> string "if" - *> lift3 - eif_then_else - parse_expr - (skip_wspace *> string "then" *> parse_expr) - (skip_wspace *> string "else" *> parse_expr) -;; - -let parse_bin_op pack = - fix - @@ fun self -> - skip_wspace - *> - let addition = skip_wspace *> char '+' >>| sAdd - and subtraction = skip_wspace *> char '-' >>| sSub - and multiplication = skip_wspace *> char '*' >>| sMul - and division = skip_wspace *> char '/' >>| sDiv - and eqality = skip_wspace *> char '=' >>| sEq - and neqality = skip_wspace *> string "!=" <|> string "<>" >>| sEq - and logand = skip_wspace *> string "&&" >>| sAnd - and logor = skip_wspace *> string "||" >>| sOr - and larger = skip_wspace *> char '>' >>| sGt - and largerEq = skip_wspace *> string ">=" >>| sGte - and less = skip_wspace *> char '<' >>| sLt - and lessEq = skip_wspace *> string "<=" >>| sLte in - let parse_expr = - choice - [ parens self - ; pack.parse_application pack - ; pack.parse_fun pack - ; pack.parse_if_then_else pack - ; parse_const - ; parse_ident - ] - and chainl1 e op = - let rec go acc = - lift2 (fun f x -> EBinaryOperation (f, acc, x)) op e >>= go <|> return acc - in - e >>= fun init -> go init - in - let ( <||> ) = chainl1 in - parse_expr - <||> multiplication - <||> division - <||> addition - <||> subtraction - <||> larger - <||> largerEq - <||> less - <||> lessEq - <||> eqality - <||> neqality - <||> logand - <||> logor - >>= fun s -> - match s with - | EBinaryOperation (_, _, _) -> return s - | _ -> fail "Error: not binary operation." -;; - -let parse_declaration pack = - fix - @@ fun _ -> - let parse_expr = - choice - [ pack.parse_bin_op pack - ; pack.parse_application pack - ; pack.parse_fun pack - ; pack.parse_if_then_else pack - ; parse_const - ; parse_ident - ] - in - skip_wspace *> string "let" *> skip_wspace1 *> option "" (string "rec" <* skip_wspace1) - >>= function - | "rec" -> - lift3 - rec_declraration - parse_uncapitalized_name - (many parse_uncapitalized_name) - (skip_wspace *> string "=" *> parse_expr) - | _ -> - lift3 - declraration - parse_uncapitalized_name - (many parse_uncapitalized_name) - (skip_wspace *> string "=" *> parse_expr) -;; - -let parse_application pack = - fix - @@ fun self -> - skip_wspace - *> (parens self - <|> - let function_parser = - choice - [ parens @@ pack.parse_fun pack - ; parens @@ pack.parse_if_then_else pack - ; parse_ident - ] - and operand_parser = - choice - [ parens @@ pack.parse_bin_op pack - ; parens self - ; parens @@ pack.parse_fun pack - ; parens @@ pack.parse_if_then_else pack - ; parse_const - ; parse_ident - ] - in - let chainl acc = lift (eapplication acc) operand_parser in - let rec go acc = chainl acc >>= go <|> return acc in - function_parser >>= fun init -> chainl init >>= fun init -> go init) -;; - -let default = { parse_bin_op; parse_application; parse_fun; parse_if_then_else } - -let parse input = - parse_string ~consume:All (many (parse_declaration default) <* skip_wspace) input -;; diff --git a/OCamlWithWeakTypeVariables/.gitignore b/OCamlWithWeakTypeVariables/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/OCamlWithWeakTypeVariables/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/OCamlWithWeakTypeVariables/.ocamlformat b/OCamlWithWeakTypeVariables/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OCamlWithWeakTypeVariables/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OCamlWithWeakTypeVariables/COPYING b/OCamlWithWeakTypeVariables/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OCamlWithWeakTypeVariables/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OCamlWithWeakTypeVariables/COPYING.CC0 b/OCamlWithWeakTypeVariables/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OCamlWithWeakTypeVariables/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OCamlWithWeakTypeVariables/COPYING.LESSER b/OCamlWithWeakTypeVariables/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OCamlWithWeakTypeVariables/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OCamlWithWeakTypeVariables/DONT_REMOVE_THIS_DIRECTORY.md b/OCamlWithWeakTypeVariables/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/OCamlWithWeakTypeVariables/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/OCamlWithWeakTypeVariables/Lambda.opam b/OCamlWithWeakTypeVariables/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/OCamlWithWeakTypeVariables/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCamlWithWeakTypeVariables/Makefile b/OCamlWithWeakTypeVariables/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OCamlWithWeakTypeVariables/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OCamlWithWeakTypeVariables/README.md b/OCamlWithWeakTypeVariables/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/OCamlWithWeakTypeVariables/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/OCamlWithWeakTypeVariables/REPL.ml b/OCamlWithWeakTypeVariables/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/OCamlWithWeakTypeVariables/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/OCamlWithWeakTypeVariables/demos/demoAO.ml b/OCamlWithWeakTypeVariables/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/OCamlWithWeakTypeVariables/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/OCamlWithWeakTypeVariables/demos/demoNO.ml b/OCamlWithWeakTypeVariables/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/OCamlWithWeakTypeVariables/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/OCamlWithWeakTypeVariables/demos/demoParse.ml b/OCamlWithWeakTypeVariables/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/OCamlWithWeakTypeVariables/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/OCamlWithWeakTypeVariables/demos/demo_input.txt b/OCamlWithWeakTypeVariables/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/OCamlWithWeakTypeVariables/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/OCamlWithWeakTypeVariables/demos/dune b/OCamlWithWeakTypeVariables/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/OCamlWithWeakTypeVariables/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/OCamlWithWeakTypeVariables/demos/interpretTests.t b/OCamlWithWeakTypeVariables/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/OCamlWithWeakTypeVariables/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/OCamlWithWeakTypeVariables/demos/parsingTests.t b/OCamlWithWeakTypeVariables/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/OCamlWithWeakTypeVariables/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/OCamlWithWeakTypeVariables/dune b/OCamlWithWeakTypeVariables/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/OCamlWithWeakTypeVariables/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/OCamlWithWeakTypeVariables/dune-project b/OCamlWithWeakTypeVariables/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/OCamlWithWeakTypeVariables/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/OCamlWithWeakTypeVariables/lib/Pprintast.ml b/OCamlWithWeakTypeVariables/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/OCamlWithWeakTypeVariables/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/OCamlWithWeakTypeVariables/lib/Pprintast.mli b/OCamlWithWeakTypeVariables/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/OCamlWithWeakTypeVariables/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/OCamlWithWeakTypeVariables/lib/Printast.ml b/OCamlWithWeakTypeVariables/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/OCamlWithWeakTypeVariables/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/OCamlWithWeakTypeVariables/lib/Printast.mli b/OCamlWithWeakTypeVariables/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/OCamlWithWeakTypeVariables/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/OCamlWithWeakTypeVariables/lib/ast.mli b/OCamlWithWeakTypeVariables/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/OCamlWithWeakTypeVariables/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/OCamlWithWeakTypeVariables/lib/dune b/OCamlWithWeakTypeVariables/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/OCamlWithWeakTypeVariables/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/OCamlWithWeakTypeVariables/lib/interpret.ml b/OCamlWithWeakTypeVariables/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/OCamlWithWeakTypeVariables/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/OCamlWithWeakTypeVariables/lib/interpret.mli b/OCamlWithWeakTypeVariables/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/OCamlWithWeakTypeVariables/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/OCamlWithWeakTypeVariables/lib/lambda.ml b/OCamlWithWeakTypeVariables/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/OCamlWithWeakTypeVariables/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/OCamlWithWeakTypeVariables/lib/lambda.mli b/OCamlWithWeakTypeVariables/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/OCamlWithWeakTypeVariables/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/OCamlWithWeakTypeVariables/lib/parser.ml b/OCamlWithWeakTypeVariables/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/OCamlWithWeakTypeVariables/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/OCamlWithWeakTypeVariables/lib/parser.mli b/OCamlWithWeakTypeVariables/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/OCamlWithWeakTypeVariables/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/OCamlWithWeakTypeVariables/lib/tests.ml b/OCamlWithWeakTypeVariables/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/OCamlWithWeakTypeVariables/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/OCamlWithWeakTypeVariables/lib/utils.ml b/OCamlWithWeakTypeVariables/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/OCamlWithWeakTypeVariables/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/OCamlWithWeakTypeVariables/lib/utils.mli b/OCamlWithWeakTypeVariables/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/OCamlWithWeakTypeVariables/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/OCamlWithWeakTypeVariables/repl.t b/OCamlWithWeakTypeVariables/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/OCamlWithWeakTypeVariables/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/OCaml_BidirectionalRecords/.gitignore b/OCaml_BidirectionalRecords/.gitignore deleted file mode 100644 index c835a77a9..000000000 --- a/OCaml_BidirectionalRecords/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs -.DS_Store -_build/ diff --git a/OCaml_BidirectionalRecords/.ocamlformat b/OCaml_BidirectionalRecords/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OCaml_BidirectionalRecords/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OCaml_BidirectionalRecords/COPYING b/OCaml_BidirectionalRecords/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OCaml_BidirectionalRecords/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OCaml_BidirectionalRecords/COPYING.CC0 b/OCaml_BidirectionalRecords/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OCaml_BidirectionalRecords/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OCaml_BidirectionalRecords/COPYING.LESSER b/OCaml_BidirectionalRecords/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OCaml_BidirectionalRecords/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OCaml_BidirectionalRecords/Makefile b/OCaml_BidirectionalRecords/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OCaml_BidirectionalRecords/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OCaml_BidirectionalRecords/OCaml_BidirectionalRecords.opam b/OCaml_BidirectionalRecords/OCaml_BidirectionalRecords.opam deleted file mode 100644 index c763acd56..000000000 --- a/OCaml_BidirectionalRecords/OCaml_BidirectionalRecords.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "OCaml with bidirectional records" -description: "Ocaml implementation with bidirectional records support" -maintainer: ["Ksenia Melashenko"] -authors: ["Ksenia Melashenko"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/ksenmel/fp2023" -bug-reports: "https://github.com/ksenmel/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "odoc" {with-doc} - "ocamlformat" {build} - "angstrom" - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCaml_BidirectionalRecords/README.md b/OCaml_BidirectionalRecords/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/OCaml_BidirectionalRecords/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/OCaml_BidirectionalRecords/demos/dune b/OCaml_BidirectionalRecords/demos/dune deleted file mode 100644 index e69de29bb..000000000 diff --git a/OCaml_BidirectionalRecords/dune b/OCaml_BidirectionalRecords/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/OCaml_BidirectionalRecords/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/OCaml_BidirectionalRecords/dune-project b/OCaml_BidirectionalRecords/dune-project deleted file mode 100644 index c3783e82a..000000000 --- a/OCaml_BidirectionalRecords/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Ksenia Melashenko") - -(maintainers "Ksenia Melashenko") - -(bug_reports "https://github.com/ksenmel/fp2023/issues") - -(homepage "https://github.com/ksenmel/fp2023") - -(package - (name OCaml_BidirectionalRecords) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "OCaml with bidirectional records") - (description - "Ocaml implementation with bidirectional records support") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - (odoc :with-doc) - (ocamlformat :build) - angstrom - base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/OCaml_BidirectionalRecords/lib/ast.ml b/OCaml_BidirectionalRecords/lib/ast.ml deleted file mode 100644 index 0e4647700..000000000 --- a/OCaml_BidirectionalRecords/lib/ast.ml +++ /dev/null @@ -1,83 +0,0 @@ -(** Copyright 2021-2023, ksenmel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type id = string [@@deriving show] - -type ty = - | TInt - | TBool - | TString - | TList of ty - | TTuple of ty list - | Unspecified - | UserDefined of id -[@@deriving show] - -type ty_bind = - { name : id - ; ty : ty - } -[@@deriving show] - -type const = - | Bool of bool - | Int of int - | Char of char - | String of string - | Nil - | Unit -[@@deriving show] - -type binop = - | Plus - | Minus - | Mult - | Div - | Mod - | And - | Or - | Eq (* = *) - | Neq (* != *) - | Lt (* < *) - | Ltq (* <= *) - | Gt (* > *) - | Gtq (* >= *) -[@@deriving show] - -type unop = - | UNot (** not a *) - | UMinus (* -5 *) - | UPlus -[@@deriving show] - -type pattern = - | PVar of ty_bind - | PConst of const - | PCons of pattern * pattern list (** PCons (p1,p2) is p1::p2 *) - | PAny (* _ *) - | PTuple of pattern list -[@@deriving show] - -type rec_flag = - | Rec - | NonRec -[@@deriving show] - -type expr = - | EVar of ty_bind - | EConst of const - | EBinOp of binop * expr * expr (** EBinOp (op,l,r) is l op r *) - | EUnOp of unop * expr (** EUnOp (op,e) is op e *) - | EFun of ty_bind * expr (** Fun x -> e *) - | ECons of expr * expr (** ECons (h,t) is list h::t *) - | ETuple of expr list (** (expr1, ..., exprn) *) - | EIfThenElse of expr * expr * expr (** IfThenElse (b,t,e) is if b then t else e *) - | ELet of rec_flag * ty_bind * expr * expr (** Let (x,e,e') is let x = e in e' *) - | EApp of expr * expr (** App (f,e) is application f e *) - | EMatch of expr * (pattern * expr) - | EUnit -[@@deriving show] - -type record = ty_bind list [@@deriving show] -type decl = rec_flag * ty_bind * expr [@@deriving show] diff --git a/OCaml_BidirectionalRecords/lib/dune b/OCaml_BidirectionalRecords/lib/dune deleted file mode 100644 index 136a53fde..000000000 --- a/OCaml_BidirectionalRecords/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name ocaml_birecords) - (public_name OCaml_BidirectionalRecords.Lib) - (modules Ast Parser Tests) - (libraries base angstrom) - (instrumentation - (backend bisect_ppx)) - (preprocess - (pps ppx_deriving.show ppx_inline_test ppx_expect)) - (inline_tests)) diff --git a/OCaml_BidirectionalRecords/lib/parser.ml b/OCaml_BidirectionalRecords/lib/parser.ml deleted file mode 100644 index 4916a9378..000000000 --- a/OCaml_BidirectionalRecords/lib/parser.ml +++ /dev/null @@ -1,166 +0,0 @@ -(** Copyright 2021-2023, ksenmel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Base -open Ast - -(* helpers *) - -let is_keyword = function - | "let" - | "if" - | "then" - | "else" - | "fun" - | "function" - | "rec" - | "true" - | "false" - | "match" - | "with" - | "in" - | "type" -> true - | _ -> false -;; - -let pws = take_while Char.is_whitespace -let pstoken s = pws *> string s -let ptoken s = pws *> s -let pparens p = pstoken "(" *> p <* pstoken ")" -let pbrackets p = pstoken "{" *> p <* pstoken "}" - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= go -;; - -let chainr1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op (e >>= go) <|> return acc in - e >>= go -;; - -(* constants *) - -let pint = - let sign = choice [ pstoken "-"; pstoken "+"; pstoken "" ] in - let rest = take_while1 Char.is_digit in - lift2 (fun sign rest -> Int.of_string (sign ^ rest)) sign rest >>| fun s -> Int s -;; - -let pbool = - choice [ pstoken "true" *> return true; pstoken "false" *> return false ] - >>| fun x -> Bool x -;; - -let pstr = char '"' *> take_till (Char.equal '"') <* char '"' >>| fun x -> String x -let pchr = char '\'' *> any_char <* char '\'' >>| fun x -> Char x -let pnil = pstoken "[]" >>| fun _ -> Nil -let punit = pstoken "()" >>| fun _ -> Unit -let const = choice [ pint; pbool; pstr; punit; pnil ] - -(* varname *) - -let varname = - let pfirst = - satisfy (fun ch -> Char.is_alphanum ch || Char.equal ch '_') >>| Char.escaped - in - let prest = - take_while (fun ch -> Char.is_alphanum ch || Char.is_digit ch || Char.equal ch '_') - in - let varname = lift2 (fun x y -> x ^ y) pfirst prest in - ptoken varname - >>= fun s -> - if is_keyword s then fail "Variable name conflicts with a keyword" else return s -;; - -let ptint = pstoken "int" *> return TInt -let ptstring = pstoken "string" *> return TString -let ptbool = pstoken "bool" *> return TBool -let unspecified = pstoken "" *> return Unspecified -let pty = choice [ ptint; ptstring; ptbool; unspecified ] - -(* typed variable *) -let tvar = - lift2 (fun name ty -> { name; ty }) varname (pstoken ":" *> pty <|> return Unspecified) -;; - -(* patterns *) - -let pvar = tvar >>| fun x -> PVar x -let pconst = const >>| fun x -> PConst x -let pany = pstoken "_" >>| fun _ -> PAny - -let pptuple pexpr = - lift2 List.cons pexpr (many1 (pstoken "," *> pexpr)) >>| fun x -> PTuple x -;; - -(* records *) - -let record = pbrackets (lift2 List.cons tvar (many1 (pstoken ";" *> tvar))) -let precord = pstoken "type" *> varname *> pstoken "=" *> record - -(* expressions *) - -let peconst = const >>| fun x -> EConst x -let pevar = tvar >>| fun x -> EVar x -let peapp e = chainl1 e (return (fun e1 e2 -> EApp (e1, e2))) - -let petuple pexpr = - lift2 List.cons pexpr (many1 (pstoken "," *> pexpr)) >>| fun x -> ETuple x -;; - -let pbranch pexpr = - lift3 - (fun e1 e2 e3 -> EIfThenElse (e1, e2, e3)) - (pstoken "if" *> pexpr) - (pstoken "then" *> pexpr) - (pstoken "else" *> pexpr) -;; - -let parsebinop op token = - pws *> pstoken token *> return (fun e1 e2 -> EBinOp (op, e1, e2)) -;; - -let mult = parsebinop Mult "*" -let div = parsebinop Div "/" -let add = parsebinop Plus "+" -let sub = parsebinop Minus "-" - -let rel = - choice - [ parsebinop Eq "=" - ; parsebinop Neq "<>" - ; parsebinop Lt "<" - ; parsebinop Ltq "<=" - ; parsebinop Gt ">" - ; parsebinop Gtq ">=" - ] -;; - -let plet pexpr = - let rec pbody pexpr = - tvar >>= fun id -> pbody pexpr <|> pstoken "=" *> pexpr >>| fun e -> EFun (id, e) - in - pstoken "let" - *> lift4 - (fun r id e1 e2 -> ELet (r, id, e1, e2)) - (pstoken "rec" *> return Rec <|> return NonRec) - (pparens tvar <|> tvar) - (pstoken "=" *> pexpr <|> pbody pexpr) - (pstoken "in" *> pexpr <|> return EUnit) -;; - -let pexpr = - fix (fun expr -> - let expr = choice [ peconst; pevar; pparens expr ] in - let expr = peapp expr <|> expr in - let expr = chainl1 expr (mult <|> div) in - let expr = chainl1 expr (add <|> sub) in - let expr = chainl1 expr rel in - let expr = petuple expr <|> expr in - let expr = pbranch expr <|> expr in - let expr = plet expr <|> expr in - expr) -;; diff --git a/OCaml_BidirectionalRecords/lib/tests.ml b/OCaml_BidirectionalRecords/lib/tests.ml deleted file mode 100644 index e4cef4004..000000000 --- a/OCaml_BidirectionalRecords/lib/tests.ml +++ /dev/null @@ -1,36 +0,0 @@ -(** Copyright 2021-2023, ksenmel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Parser - -(* parse *) - -let parse p s show_program = - match parse_string ~consume:All p s with - | Ok ast -> print_endline (show_program ast) - | Error msg -> failwith msg -;; - -let%expect_test _ = - parse pexpr "let rec fact = if n < 1 then 1 else n * fact (n - 1)" Ast.show_expr; - [%expect - {| - (Ast.ELet (Ast.Rec, { Ast.name = "fact"; ty = Ast.Unspecified }, - (Ast.EIfThenElse ( - (Ast.EBinOp (Ast.Lt, - (Ast.EVar { Ast.name = "n"; ty = Ast.Unspecified }), - (Ast.EConst (Ast.Int 1)))), - (Ast.EConst (Ast.Int 1)), - (Ast.EBinOp (Ast.Mult, - (Ast.EVar { Ast.name = "n"; ty = Ast.Unspecified }), - (Ast.EApp ((Ast.EVar { Ast.name = "fact"; ty = Ast.Unspecified }), - (Ast.EBinOp (Ast.Minus, - (Ast.EVar { Ast.name = "n"; ty = Ast.Unspecified }), - (Ast.EConst (Ast.Int 1)))) - )) - )) - )), - Ast.EUnit)) |}] -;; diff --git a/OCaml_ExtensibleVariantTypes/.gitignore b/OCaml_ExtensibleVariantTypes/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/OCaml_ExtensibleVariantTypes/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/OCaml_ExtensibleVariantTypes/.ocamlformat b/OCaml_ExtensibleVariantTypes/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OCaml_ExtensibleVariantTypes/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OCaml_ExtensibleVariantTypes/COPYING b/OCaml_ExtensibleVariantTypes/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OCaml_ExtensibleVariantTypes/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OCaml_ExtensibleVariantTypes/COPYING.CC0 b/OCaml_ExtensibleVariantTypes/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OCaml_ExtensibleVariantTypes/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OCaml_ExtensibleVariantTypes/COPYING.LESSER b/OCaml_ExtensibleVariantTypes/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OCaml_ExtensibleVariantTypes/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OCaml_ExtensibleVariantTypes/Makefile b/OCaml_ExtensibleVariantTypes/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OCaml_ExtensibleVariantTypes/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OCaml_ExtensibleVariantTypes/OCaml_ExtensibleVariantTypes.opam b/OCaml_ExtensibleVariantTypes/OCaml_ExtensibleVariantTypes.opam deleted file mode 100644 index dfcabb356..000000000 --- a/OCaml_ExtensibleVariantTypes/OCaml_ExtensibleVariantTypes.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "Interpreter of OCaml with extensible variant types" -description: "Interpreter of OCaml with extensible variant types" -maintainer: ["David Akhmedov"] -authors: ["David Akhmedov"] -license: "LGPL-3.0-or-later" -homepage: - "https://github.com/Kakadu/fp2023/tree/master/OCaml_ExtensibleVariantTypes" -bug-reports: "https://github.com/Kakadu/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OCaml_ExtensibleVariantTypes/README.md b/OCaml_ExtensibleVariantTypes/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/OCaml_ExtensibleVariantTypes/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/OCaml_ExtensibleVariantTypes/REPL.ml b/OCaml_ExtensibleVariantTypes/REPL.ml deleted file mode 100644 index 690782a13..000000000 --- a/OCaml_ExtensibleVariantTypes/REPL.ml +++ /dev/null @@ -1,8 +0,0 @@ -open OCaml_ExtensibleVariantTypes_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Parser.parse_program s with - | Ok ast -> Format.printf "%a\n%!" Ast.pp_prog ast - | Error msg -> print_string msg -;; diff --git a/OCaml_ExtensibleVariantTypes/demos/demoParse.ml b/OCaml_ExtensibleVariantTypes/demos/demoParse.ml deleted file mode 100644 index 690782a13..000000000 --- a/OCaml_ExtensibleVariantTypes/demos/demoParse.ml +++ /dev/null @@ -1,8 +0,0 @@ -open OCaml_ExtensibleVariantTypes_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Parser.parse_program s with - | Ok ast -> Format.printf "%a\n%!" Ast.pp_prog ast - | Error msg -> print_string msg -;; diff --git a/OCaml_ExtensibleVariantTypes/demos/demo_input.txt b/OCaml_ExtensibleVariantTypes/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/OCaml_ExtensibleVariantTypes/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/OCaml_ExtensibleVariantTypes/demos/dune b/OCaml_ExtensibleVariantTypes/demos/dune deleted file mode 100644 index 721db40a1..000000000 --- a/OCaml_ExtensibleVariantTypes/demos/dune +++ /dev/null @@ -1,14 +0,0 @@ -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries OCaml_ExtensibleVariantTypes_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/OCaml_ExtensibleVariantTypes/demos/parsingTests.t b/OCaml_ExtensibleVariantTypes/demos/parsingTests.t deleted file mode 100644 index 7467ea86e..000000000 --- a/OCaml_ExtensibleVariantTypes/demos/parsingTests.t +++ /dev/null @@ -1,16 +0,0 @@ - $ ./demoParse.exe <<-EOF - > let rec f n = if n = 0 then 1 else n * f (n-1) - > EOF - [(DLet (Recursive, (Ident "f"), - (EFun - (EApp ((EId (Ident "n")), - (EIf ((EBinop ((EId (Ident "n")), Eq, (EConst (CInt 0)))), - (EConst (CInt 1)), - (EBinop ((EId (Ident "n")), Mul, - (EApp ((EId (Ident "f")), - (EBinop ((EId (Ident "n")), Sub, (EConst (CInt 1)))))) - )) - )) - ))) - )) - ] diff --git a/OCaml_ExtensibleVariantTypes/dune b/OCaml_ExtensibleVariantTypes/dune deleted file mode 100644 index 859c810aa..000000000 --- a/OCaml_ExtensibleVariantTypes/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries OCaml_ExtensibleVariantTypes.Lib stdio angstrom)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/OCaml_ExtensibleVariantTypes/dune-project b/OCaml_ExtensibleVariantTypes/dune-project deleted file mode 100644 index 9792e2b9c..000000000 --- a/OCaml_ExtensibleVariantTypes/dune-project +++ /dev/null @@ -1,31 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "David Akhmedov") - -(maintainers "David Akhmedov") - -(bug_reports "https://github.com/Kakadu/fp2023/issues") - -(homepage - "https://github.com/Kakadu/fp2023/tree/master/OCaml_ExtensibleVariantTypes") - -(package - (name OCaml_ExtensibleVariantTypes) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "Interpreter of OCaml with extensible variant types") - (description "Interpreter of OCaml with extensible variant types") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build))) diff --git a/OCaml_ExtensibleVariantTypes/lib/ast.ml b/OCaml_ExtensibleVariantTypes/lib/ast.ml deleted file mode 100644 index 9753b28f6..000000000 --- a/OCaml_ExtensibleVariantTypes/lib/ast.ml +++ /dev/null @@ -1,68 +0,0 @@ -(** Copyright 2023-2024, David Akhmedov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type const = - | CInt of int - | CString of string - | CBool of bool - | CNil -[@@deriving eq, show { with_path = false }] - -type bin_op = - | Add (* + *) - | Sub (* - *) - | Mul (* * *) - | Div (* / *) - | Leq (* <= *) - | Less (* < *) - | Geq (* >= *) - | Gre (* > *) - | Eq (* == *) - | Neq (* != *) - | And (* && *) - | Or (* || *) -[@@deriving eq, show { with_path = false }] - -type unary_op = - | Plus (* ~+ *) - | Minus (* ~- *) - | Not (* ~not *) -[@@deriving eq, show { with_path = false }] - -type ident = Ident of string [@@deriving eq, show { with_path = false }] - -type capitalized_ident = Capitalized_ident of string -[@@deriving eq, show { with_path = false }] - -type expr = - | EEmpty (* Empty expression *) - | EConst of const (* Const. Examples: 100; true; "hello, world!" *) - | EBinop of - expr * bin_op * expr (* Binary operation. Examples: 2 + 2; (234 * 234) + 234*) - | EUnop of unary_op * expr (* Unary operation. Examples: -(1); (+b) *) - | EId of ident (* Identifier. Examples: a, b, c*) - | EFun of expr (* Anonymous function. Examples: fun x -> x + 1*) - | EApp of expr * expr (* Application. Examples: f (x - 1) *) - | EIf of expr * expr * expr (* Conditional. Examples: if x >= y then x - y else y - x*) - | ETuple of expr list (* Tuple. Examples: (1, 2, 3)*) -[@@deriving eq, show { with_path = false }] - -type rec_flag = - | Recursive - | Not_recursive -[@@deriving eq, show { with_path = false }] - -type decl = DLet of rec_flag * ident * expr [@@deriving eq, show { with_path = false }] -type prog = decl list [@@deriving show { with_path = false }] - -let econst c = EConst c -let ebinop e1 op e2 = EBinop (e1, op, e2) -let eunop op e = EUnop (op, e) -let eid i = EId i -let efun e1 = EFun e1 -let eapp id args = EApp (id, args) -let eif e1 e2 e3 = EIf (e1, e2, e3) -let etuple l = ETuple l -let dlet rf i args_e = DLet (rf, i, args_e) -let prog (d_l : decl list) : prog = d_l diff --git a/OCaml_ExtensibleVariantTypes/lib/dune b/OCaml_ExtensibleVariantTypes/lib/dune deleted file mode 100644 index 2e5011bb5..000000000 --- a/OCaml_ExtensibleVariantTypes/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name OCaml_ExtensibleVariantTypes_lib) - (public_name OCaml_ExtensibleVariantTypes.Lib) - (modules Ast Parser) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) - -(library - (name tests) - (modules tests) - (libraries OCaml_ExtensibleVariantTypes_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/OCaml_ExtensibleVariantTypes/lib/parser.ml b/OCaml_ExtensibleVariantTypes/lib/parser.ml deleted file mode 100644 index 250a19fcf..000000000 --- a/OCaml_ExtensibleVariantTypes/lib/parser.ml +++ /dev/null @@ -1,297 +0,0 @@ -(** Copyright 2023-2024, David Akhmedov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Ast - -let is_space = function - | ' ' | '\t' | '\r' | '\n' -> true - | _ -> false -;; - -let char_bool (c1 : char) = function - | c2 -> c1 = c2 -;; - -let parse_space = take_while is_space -let parse_space1 = take_while1 is_space -let parse_token p = parse_space *> p -let parse_token1 p = parse_space1 *> p -let parse_stoken s = parse_token @@ string s -let parse_stoken1 s = parse_token1 @@ string s -let parse_parens p = parse_stoken "(" *> p <* parse_stoken ")" -let spaces = skip_while is_space - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_lower = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_upper = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_letter c = is_lower c || is_upper c -let is_ident_char c = is_digit c || is_letter c -let is_sign c = c = '+' || c = '-' - -let keywords = - [ "if" - ; "then" - ; "else" - ; "let" - ; "rec" - ; "true" - ; "false" - ; "match" - ; "with" - ; "in" - ; "fun" - ; "type" - ; "int" - ; "bool" - ; "when" - ; "function" - ] -;; - -let is_keyword s = List.mem s keywords - -(****************************************************** Consts ******************************************************) -let parse_int = - parse_token - @@ lift2 - (fun hd tl -> hd, tl) - (satisfy (fun ch -> ch = '-' || ch = '+' || is_digit ch)) - (take_while (fun ch -> is_digit ch)) - >>= fun (hd, tl) -> - if is_sign hd && tl = "" - then fail "Can't parse int" - else return @@ CInt (int_of_string @@ String.make 1 hd ^ tl) -;; - -let parse_string = - parse_token - @@ choice - ~failure_msg:"Can't parse string" - [ char '"' *> take_while (fun ch -> ch != '"') <* char '"' ] - >>= fun res_string -> return @@ CString res_string -;; - -let parse_bool = - choice [ parse_stoken "true" *> return true; parse_stoken "false" *> return false ] - >>= fun res_bool -> return @@ Ast.CBool res_bool -;; - -let parse_nil = parse_stoken "Nil" *> return CNil -let parse_const = choice [ parse_bool; parse_int; parse_string; parse_nil ] -let parse_const_to_expr = parse_const >>= fun res -> return @@ EConst res - -(****************************************************** Operators ******************************************************) -let parse_str_bin_op = - choice - ~failure_msg:"Can't parse binary op" - [ parse_stoken "+" *> return Add - ; parse_stoken "-" *> return Sub - ; parse_stoken "*" *> return Mul - ; parse_stoken "/" *> return Div - ; parse_stoken "<=" *> return Leq - ; parse_stoken "<" *> return Less - ; parse_stoken ">=" *> return Geq - ; parse_stoken ">" *> return Gre - ; parse_stoken "==" *> return Eq - ; parse_stoken "!=" *> return Neq - ; parse_stoken "&&" *> return And - ; parse_stoken "||" *> return Or - ] -;; - -let parse_unary_op = - choice - [ parse_stoken "+" *> return Plus - ; parse_stoken "-" *> return Minus - ; parse_stoken "not" *> return Not - ] -;; - -let parse_satisfy_ops op parser = - parse_space - *> - let* chars = - take_while (fun c -> not (is_digit c or is_ident_char c or c = '(' or is_space c)) - in - if chars = op then parser else fail "The operators don't match" -;; - -(****************************************************** Tuple ******************************************************) - -let parse_tuple parse_expr = - let* expr_list_res = sep_by1 (parse_stoken ",") parse_expr in - match expr_list_res with - | [ e ] -> return e - | _ -> return @@ etuple expr_list_res -;; - -(****************************************************** Identifiers, let-bindings, anonymous functions ******************************************************) - -let parse_identifier = - parse_token - @@ lift2 - (fun hd tl -> String.make 1 hd ^ tl) - (satisfy (fun ch -> ch = '_' || is_lower ch)) - (take_while (fun ch -> ch = '_' || is_ident_char ch)) - >>= fun str_res -> - if is_keyword str_res - then fail "invalid syntax" - else if str_res = "_" - then fail "_ is not supported" - else return @@ Ident str_res -;; - -let parse_identifier_to_expr = parse_identifier >>= fun id -> return @@ eid id - -let parse_params_and_expr parse_expr sep = - let parse_param = - parse_parens (parse_tuple parse_identifier_to_expr) <|> parse_identifier_to_expr - in - fix - @@ fun parse_params_and_expr -> - let* parameter = parse_param in - let* expr = - choice [ parse_space1 *> parse_params_and_expr; parse_satisfy_ops sep parse_expr ] - in - return @@ efun (eapp parameter expr) -;; - -let parse_bind_let parse_expr = - parse_stoken "let" - *> lift3 - dlet - (parse_stoken1 "rec" *> return Recursive <|> return Not_recursive) - (parse_token1 parse_identifier) - (parse_params_and_expr parse_expr "=" <|> parse_satisfy_ops "=" parse_expr) -;; - -let parse_anon_fun parse_expr = - parse_stoken "fun" *> parse_space1 *> parse_params_and_expr parse_expr "->" -;; - -(****************************************************** Branching ******************************************************) - -let parse_branching parse_expr = - lift3 - eif - (parse_stoken "if" *> parse_token1 parse_expr) - (parse_stoken1 "then" *> parse_token1 parse_expr) - (parse_stoken1 "else" *> parse_token1 parse_expr) -;; - -(****************************************************** Application ******************************************************) - -let binop_binder str_op bin_op = - let helper bin_op x y = ebinop x bin_op y in - parse_satisfy_ops str_op (return @@ helper bin_op) -;; - -let add = binop_binder "+" Add -let sub = binop_binder "-" Sub -let mul = binop_binder "*" Mul -let div = binop_binder "/" Div -let geq = binop_binder ">=" Geq -let gre = binop_binder ">" Gre -let leq = binop_binder "<=" Leq -let less = binop_binder "<" Less -let eq = binop_binder "=" Eq -let neq = binop_binder "!=" Neq -let and_l = binop_binder "&&" And -let or_l = binop_binder "||" Or - -let chainl1 parse_e op = - let rec go acc = lift2 (fun f x -> f acc x) op parse_e >>= go <|> return acc in - parse_e >>= fun init -> go init -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let parse_bin_op_app parse_expr = - let term = chainl1 parse_expr (mul <|> div) in - let term = chainl1 term (add <|> sub) in - let term = chainl1 term (choice [ geq; gre; leq; less; eq; neq ]) in - chainr1 term (choice [ or_l; and_l ]) -;; - -let rec parse_un_op_app parse_expr = - let* unop = parse_unary_op in - let* res = - take_while (fun c -> not (is_digit c or is_ident_char c or c = '(' or is_space c)) - in - if res = "" - then - let* expr = - choice - [ parse_un_op_app parse_expr - ; parse_parens (parse_un_op_app parse_expr) - ; parse_fun_app parse_expr - ; parse_parens (parse_fun_app parse_expr) - ] - in - return @@ eunop unop expr - else fail "This is not un op" - -and parse_fun_app parse_expr = - let rec parse_fun_app_currying app1 = - let* app2 = - choice - [ parse_str_bin_op *> return EEmpty - ; parse_expr - ; parse_parens (parse_app parse_expr) - ] - in - if app2 = EEmpty - then fail "Can't proccess bin op, only fun app" - else parse_fun_app_currying (eapp app1 app2) <|> return (eapp app1 app2) - in - let* app1 = parse_expr in - parse_fun_app_currying app1 <|> return app1 - -and parse_app parse_expr = - let parser_ehelper = choice [ parse_fun_app parse_expr; parse_expr ] in - parse_bin_op_app parser_ehelper -;; - -let parse_expr = - fix (fun parse_expr -> - let parser_ehelper = - choice - [ parse_parens parse_expr - ; parse_const_to_expr - ; parse_identifier_to_expr - ; parse_anon_fun parse_expr - ; parse_branching parse_expr - ] - in - let parser_ehelper = choice [ parser_ehelper; parse_un_op_app parser_ehelper ] in - let parser_ehelper = parse_app parser_ehelper in - let parser_ehelper = parse_tuple parser_ehelper in - choice ~failure_msg:"Can't parse expr" [ parser_ehelper ]) -;; - -let parse_decls = - lift prog (many (parse_bind_let parse_expr <* (parse_stoken ";;" <|> parse_space))) -;; - -let parse_program s = - match Angstrom.parse_string ~consume:Consume.All parse_decls s with - | Ok v -> Ok v - | Error msg -> - (match msg with - | ": end_of_input" -> Error "Can't parse decl" - | _ -> Error msg) -;; diff --git a/OCaml_ExtensibleVariantTypes/lib/tests.ml b/OCaml_ExtensibleVariantTypes/lib/tests.ml deleted file mode 100644 index b70eaf08c..000000000 --- a/OCaml_ExtensibleVariantTypes/lib/tests.ml +++ /dev/null @@ -1,172 +0,0 @@ -(** Copyright 2023-2024, David Akhmedov *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open OCaml_ExtensibleVariantTypes_lib - -let parse_test s expected_res = - match Parser.parse_program s with - | Ok actual -> List.equal Ast.equal_decl expected_res actual - | Error err -> - Format.printf "%s\n" err; - false -;; - -let%test _ = - parse_test - "let a = 5 + 6" - [ DLet (Not_recursive, Ident "a", EBinop (EConst (CInt 5), Add, EConst (CInt 6))) ] -;; - -let%test _ = - parse_test - "let rec f n = if n = 0 then 1 else n * f (n-1)" - [ DLet - ( Recursive - , Ident "f" - , EFun - (EApp - ( EId (Ident "n") - , EIf - ( EBinop (EId (Ident "n"), Eq, EConst (CInt 0)) - , EConst (CInt 1) - , EBinop - ( EId (Ident "n") - , Mul - , EApp - ( EId (Ident "f") - , EBinop (EId (Ident "n"), Sub, EConst (CInt 1)) ) ) ) )) ) - ] -;; - -let%test _ = - parse_test - "let f x y = g x + g y" - [ DLet - ( Not_recursive - , Ident "f" - , EFun - (EApp - ( EId (Ident "x") - , EFun - (EApp - ( EId (Ident "y") - , EBinop - ( EApp (EId (Ident "g"), EId (Ident "x")) - , Add - , EApp (EId (Ident "g"), EId (Ident "y")) ) )) )) ) - ] -;; - -let%test _ = - parse_test - "let g x y = f x1 x2 (x3*x3) + f x3 x2 (x1)" - [ DLet - ( Not_recursive - , Ident "g" - , EFun - (EApp - ( EId (Ident "x") - , EFun - (EApp - ( EId (Ident "y") - , EBinop - ( EApp - ( EApp - ( EApp (EId (Ident "f"), EId (Ident "x1")) - , EId (Ident "x2") ) - , EBinop (EId (Ident "x3"), Mul, EId (Ident "x3")) ) - , Add - , EApp - ( EApp - ( EApp (EId (Ident "f"), EId (Ident "x3")) - , EId (Ident "x2") ) - , EId (Ident "x1") ) ) )) )) ) - ] -;; - -let%test _ = - parse_test - "let a = fun (x,y) (z,w) k-> (x,y)" - [ DLet - ( Not_recursive - , Ident "a" - , EFun - (EApp - ( ETuple [ EId (Ident "x"); EId (Ident "y") ] - , EFun - (EApp - ( ETuple [ EId (Ident "z"); EId (Ident "w") ] - , EFun - (EApp - (EId (Ident "k"), ETuple [ EId (Ident "x"); EId (Ident "y") ])) - )) )) ) - ] -;; - -let%test _ = - parse_test - "let a = (fun k -> k+2) 3" - [ DLet - ( Not_recursive - , Ident "a" - , EApp - ( EFun (EApp (EId (Ident "k"), EBinop (EId (Ident "k"), Add, EConst (CInt 2)))) - , EConst (CInt 3) ) ) - ] -;; - -let%test _ = - parse_test - "let s = 231, 21, (2323 + 23, 432)" - [ DLet - ( Not_recursive - , Ident "s" - , ETuple - [ EConst (CInt 231) - ; EConst (CInt 21) - ; ETuple - [ EBinop (EConst (CInt 2323), Add, EConst (CInt 23)); EConst (CInt 432) ] - ] ) - ] -;; - -let%test _ = - parse_test - "let s = -f 3" - [ DLet - (Not_recursive, Ident "s", EUnop (Minus, EApp (EId (Ident "f"), EConst (CInt 3)))) - ] -;; - -let%test _ = - parse_test - "let s = - -f 3" - [ DLet - ( Not_recursive - , Ident "s" - , EUnop (Minus, EUnop (Minus, EApp (EId (Ident "f"), EConst (CInt 3)))) ) - ] -;; - -let%test _ = - parse_test - "let s = f -3" - [ DLet (Not_recursive, Ident "s", EBinop (EId (Ident "f"), Sub, EConst (CInt 3))) ] -;; - -let%test _ = - parse_test - "let s = f (-3)" - [ DLet (Not_recursive, Ident "s", EApp (EId (Ident "f"), EConst (CInt (-3)))) ] -;; - -let%test _ = - parse_test - "let s = - -f -1" - [ DLet - ( Not_recursive - , Ident "s" - , EBinop (EUnop (Minus, EUnop (Minus, EId (Ident "f"))), Sub, EConst (CInt 1)) ) - ] -;; diff --git a/OCaml_ExtensibleVariantTypes/repl.t b/OCaml_ExtensibleVariantTypes/repl.t deleted file mode 100644 index 87e4669c2..000000000 --- a/OCaml_ExtensibleVariantTypes/repl.t +++ /dev/null @@ -1,5 +0,0 @@ - $ ./REPL.exe <<-EOF - > let s = 2+2 - [(DLet (Not_recursive, (Ident "s"), - (EBinop ((EConst (CInt 2)), Add, (EConst (CInt 2)))))) - ] diff --git a/Ocaml+ADT/.gitignore b/Ocaml+ADT/.gitignore deleted file mode 100644 index e74220529..000000000 --- a/Ocaml+ADT/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs -.DS_Store -_build/ \ No newline at end of file diff --git a/Ocaml+ADT/.ocamlformat b/Ocaml+ADT/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Ocaml+ADT/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Ocaml+ADT/COPYING b/Ocaml+ADT/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Ocaml+ADT/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Ocaml+ADT/COPYING.CC0 b/Ocaml+ADT/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Ocaml+ADT/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Ocaml+ADT/COPYING.LESSER b/Ocaml+ADT/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Ocaml+ADT/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Ocaml+ADT/Makefile b/Ocaml+ADT/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Ocaml+ADT/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Ocaml+ADT/Ocaml+ADT.opam b/Ocaml+ADT/Ocaml+ADT.opam deleted file mode 100644 index 59fa025e1..000000000 --- a/Ocaml+ADT/Ocaml+ADT.opam +++ /dev/null @@ -1,33 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "Ocaml with ADT" -description: "Ocaml implementation with ADT support" -maintainer: ["Kirill Shishin"] -authors: ["Kirill Shishin"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/tepa46/fp2023" -bug-reports: "https://github.com/tepa46/fp2023/issues" -depends: [ - "dune" {>= "3.7"} - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "odoc" {with-doc} - "ocamlformat" {build} - "angstrom" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Ocaml+ADT/README.md b/Ocaml+ADT/README.md deleted file mode 100644 index 39467966e..000000000 --- a/Ocaml+ADT/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Ocaml with ADT - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Kirill Shishin, kirill.a.shishin@gmail.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Ocaml+ADT/demos/demoFact.ml b/Ocaml+ADT/demos/demoFact.ml deleted file mode 100644 index ff4bd892b..000000000 --- a/Ocaml+ADT/demos/demoFact.ml +++ /dev/null @@ -1,11 +0,0 @@ -open Ocamladt_lib - -let () = - let s = - "let rec factorial_recursive = fun (n: int) -> if n <= 1 then 1 else n * \ - factorial_recursive (n - 1)" - in - match Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n" Ast.pp_program ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Ocaml+ADT/demos/demoFact.t b/Ocaml+ADT/demos/demoFact.t deleted file mode 100644 index 551e076e5..000000000 --- a/Ocaml+ADT/demos/demoFact.t +++ /dev/null @@ -1,12 +0,0 @@ - $ dune exec demoFact - [(DLet - ((DRec true), (LName "factorial_recursive"), (DType TEmptyType), - (EFun (((LName "n"), (DType TInt)), - (EIf ((EBinop (Leq, (EVar (LName "n")), (EInt 1))), (EInt 1), - (EBinop (Mul, (EVar (LName "n")), - (EApp ((EVar (LName "factorial_recursive")), - (EBinop (Sub, (EVar (LName "n")), (EInt 1))))) - )) - )) - )))) - ] diff --git a/Ocaml+ADT/demos/dune b/Ocaml+ADT/demos/dune deleted file mode 100644 index edd297fc2..000000000 --- a/Ocaml+ADT/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demoFact) - (modules demoFact) - (public_name demoFact) - (libraries ocamladt_lib) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demoFact})) diff --git a/Ocaml+ADT/dune b/Ocaml+ADT/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/Ocaml+ADT/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/Ocaml+ADT/dune-project b/Ocaml+ADT/dune-project deleted file mode 100644 index 7af9f5889..000000000 --- a/Ocaml+ADT/dune-project +++ /dev/null @@ -1,31 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Kirill Shishin") - -(maintainers "Kirill Shishin") - -(bug_reports "https://github.com/tepa46/fp2023/issues") - -(homepage "https://github.com/tepa46/fp2023") - -(package - (name Ocaml+ADT) ; - (synopsis "Ocaml with ADT") - (description "Ocaml implementation with ADT support") - (version 0.1) - (depends - dune - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - (odoc :with-doc) - (ocamlformat :build) - angstrom - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Ocaml+ADT/lib/ast.ml b/Ocaml+ADT/lib/ast.ml deleted file mode 100644 index b0e1b6e70..000000000 --- a/Ocaml+ADT/lib/ast.ml +++ /dev/null @@ -1,118 +0,0 @@ -(** Copyright 2021-2023, tepa46 *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type binop = - | Add (** + *) - | Sub (** - *) - | Mul (** * *) - | Div (** / *) - | Eq (** == *) - | Neq (** <> *) - | Les (** < *) - | Leq (** <= *) - | Gre (** > *) - | Geq (** >= *) - | And (** && *) - | Or (** || *) - | Cons (** :: *) -[@@deriving eq, show { with_path = false }] - -let bop_add = Add -let bop_sub = Sub -let bop_mul = Mul -let bop_div = Div -let bop_eq = Eq -let bop_neq = Neq -let bop_les = Les -let bop_leq = Leq -let bop_gre = Gre -let bop_geq = Geq -let bop_and = And -let bop_or = Or -let bop_cons = Cons - -type decl_name = - | LName of string (* abc, aBc *) - | UName of string (* Number *) -[@@deriving eq, show { with_path = false }] - -and decl_type = - | DType of decl_type - | TEmptyType - | TInt - | TFloat - | TString - | TBool - | TFun of decl_type * decl_type - | TVar of decl_name - | TList of decl_type - | TTuple of decl_type list -[@@deriving eq, show { with_path = false }] - -let lname str = LName str -let uname str = UName str -let dtype decl_type = DType decl_type -let temptytype = TEmptyType -let tint = TInt -let tfloat = TFloat -let tstring = TString -let tbool = TBool -let tfun decl_type1 decl_type2 = TFun (decl_type1, decl_type2) -let tvar string = TVar string -let tlist decl_type = TList decl_type -let ttuple decl_type_list = TTuple decl_type_list - -type decl_rec = DRec of bool [@@deriving eq, show { with_path = false }] - -let drec bool = DRec bool - -(* some decl_name's will be replaced with pattern soon *) -type pattern = - | PNill (* [] *) - | PString of string - | PBool of bool - | PInt of int - | PFloat of float - | PVar of decl_name - | PWild - | PCons of pattern * pattern - | PTuple of pattern list -[@@deriving eq, show { with_path = false }] - -type let_decl = decl_rec * decl_name * decl_type * decl_exp -[@@deriving eq, show { with_path = false }] - -and type_decl = decl_name * (decl_name * decl_type) list -[@@deriving eq, show { with_path = false }] - -and decl_exp = - | EInt of int - | EString of string - | EBool of bool - | EVar of decl_name - | ETuple of decl_exp list - | EBinop of binop * decl_exp * decl_exp - | EFun of (decl_name * decl_type) * decl_exp - | ELet of let_decl * decl_exp - | EApp of decl_exp * decl_exp - | EIf of decl_exp * decl_exp * decl_exp -[@@deriving eq, show { with_path = false }] - -and decl = - | DLet of let_decl - | DType of type_decl -[@@deriving eq, show { with_path = false }] - -let eint num = EInt num -let estring str = EString str -let ebool bool = EBool bool -let evar var = EVar var -let ebinop binop decl_exp1 decl_exp2 = EBinop (binop, decl_exp1, decl_exp2) -let efun (string, decl_type) decl_exp = EFun ((string, decl_type), decl_exp) -let elet let_decl decl_exp = ELet (let_decl, decl_exp) -let eapp decl_exp1 decl_exp2 = EApp (decl_exp1, decl_exp2) -let eif decl_exp1 decl_exp2 decl_exp3 = EIf (decl_exp1, decl_exp2, decl_exp3) -let dlet bool decl_name decl_type decl_exp = DLet (bool, decl_name, decl_type, decl_exp) - -type program = decl list [@@deriving eq, show { with_path = false }] diff --git a/Ocaml+ADT/lib/dune b/Ocaml+ADT/lib/dune deleted file mode 100644 index c1c4afb2a..000000000 --- a/Ocaml+ADT/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name ocamladt_lib) - (public_name Ocaml+ADT.Lib) - (modules Ast Parser) - (libraries angstrom) - (inline_tests) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx))) diff --git a/Ocaml+ADT/lib/parser.ml b/Ocaml+ADT/lib/parser.ml deleted file mode 100644 index 3971c6978..000000000 --- a/Ocaml+ADT/lib/parser.ml +++ /dev/null @@ -1,526 +0,0 @@ -(** Copyright 2021-2023, tepa46 *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Angstrom -open Format - -let is_keyword = function - | "and" - | "as" - | "assert" - | "asr" - | "begin" - | "class" - | "constraint" - | "do" - | "done" - | "downto" - | "else" - | "end" - | "exception" - | "external" - | "false" - | "for" - | "fun" - | "function" - | "functor" - | "if" - | "in" - | "include" - | "inherit" - | "initializer" - | "land" - | "lazy" - | "let" - | "lor" - | "lsl" - | "lsr" - | "lxor" - | "match" - | "method" - | "mod" - | "module" - | "mutable" - | "new" - | "nonrec" - | "object" - | "of" - | "open" - | "or" - | "private" - | "rec" - | "sig" - | "struct" - | "then" - | "to" - | "true" - | "try" - | "type" - | "val" - | "virtual" - | "when" - | "while" - | "with" -> true - | _ -> false -;; - -let letdecl a b c d = a, b, c, d - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_wildcard = function - | '_' -> true - | _ -> false -;; - -let is_apostrophe = function - | '\'' -> true - | _ -> false -;; - -let is_lchar = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_uchar = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_char ch = is_lchar ch || is_uchar ch - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let spaces = take_while is_space -let pchunk p = spaces *> p -let check_chunk s = pchunk @@ string s -let pparens p = check_chunk "(" *> p <* check_chunk ")" - -(* variable and constructors parser *) -let pvarname = - pchunk - (take_while (fun ch -> is_uchar ch || is_digit ch) - >>= function - | "" -> - take_while1 (fun ch -> - is_wildcard ch || is_apostrophe ch || is_char ch || is_digit ch) - >>= fun str -> if is_keyword str then fail "invalid var name" else return str - | _ -> fail "invalid var name") -;; - -let pconstrname = - pchunk - (take_while (fun ch -> is_lchar ch || is_digit ch) - >>= function - | "" -> - take_while1 (fun ch -> - is_wildcard ch || is_apostrophe ch || is_char ch || is_digit ch) - >>= fun str -> if is_keyword str then fail "invalid constr name" else return str - | _ -> fail "invalid constr name") -;; - -(* type parser *) - -let pftbase pftype = - choice - [ pparens pftype - ; check_chunk "int" *> return tint - ; check_chunk "float" *> return tfloat - ; check_chunk "string" *> return tstring - ; check_chunk "bool" *> return tbool - ; tvar <$> (lname <$> pvarname) - ] -;; - -let pftlist pft = tlist <$> pft <* check_chunk "list" - -let pfttuple pft = - sep_by (check_chunk "*") pft - >>= function - | [] -> pft - | [ h ] -> return h - | h :: tl -> return (ttuple (h :: tl)) -;; - -let pftfun = check_chunk "->" *> return (fun type1 type2 -> tfun type1 type2) - -let pftype = - fix - @@ fun pftype -> - let pft = pftbase pftype in - let pft = pftlist pft <|> pft in - let pft = pfttuple pft <|> pft in - chainr1 pft pftfun -;; - -(* expression parser *) - -let pfelet pfexp = - check_chunk "let" - *> lift4 - letdecl - (drec <$> (check_chunk "rec" *> return true <|> return false)) - (lname <$> pvarname) - (dtype <$> (check_chunk ":" *> pftype <|> return temptytype)) - (check_chunk "=" *> pfexp) -;; - -let pfe_number = int_of_string <$> take_while1 is_digit -let pfe_string = check_chunk "\"" *> take_while (fun ch -> ch != '\"') <* check_chunk "\"" -let pfe_bool = check_chunk "true" *> return true <|> check_chunk "false" *> return false - -let pfebase pfexp = - choice - [ pparens pfexp - ; eint <$> pchunk pfe_number - ; ebool <$> pfe_bool - ; evar <$> (lname <$> pvarname) - ; estring <$> pfe_string - ] -;; - -let pfefuntype = - pparens - (pvarname (* change to pattern parser *) - >>= fun n -> - check_chunk ":" *> (pftype >>= fun t -> return (lname n, dtype t)) - <|> return (lname n, dtype temptytype)) -;; - -let pfefun pfe = - fix @@ fun pfefun -> lift2 efun pfefuntype (pfefun <|> check_chunk "->" *> pfe) -;; - -let pfeif pfexp = - fix - @@ fun pfeif -> - lift3 - eif - (check_chunk "if" *> (pfeif <|> pfexp)) - (check_chunk "then" *> (pfeif <|> pfexp)) - (check_chunk "else" *> (pfeif <|> pfexp)) -;; - -let pfeapp pfe = chainl1 pfe (return (fun exp1 exp2 -> eapp exp1 exp2)) - -(* parse operators *) - -let fmul = check_chunk "*" *> return (fun exp1 exp2 -> ebinop bop_mul exp1 exp2) -let pfemul pfe = chainl1 pfe fmul -let fdiv = check_chunk "/" *> return (fun exp1 exp2 -> ebinop bop_div exp1 exp2) -let pfediv pfe = chainl1 pfe fdiv -let fadd = check_chunk "+" *> return (fun exp1 exp2 -> ebinop bop_add exp1 exp2) -let pfeadd pfe = chainl1 pfe fadd -let fsub = check_chunk "-" *> return (fun exp1 exp2 -> ebinop bop_sub exp1 exp2) -let pfesub pfe = chainl1 pfe fsub -let feq = check_chunk "==" *> return (fun exp1 exp2 -> ebinop bop_eq exp1 exp2) -let pfeeq pfe = chainl1 pfe feq -let fneq = check_chunk "<>" *> return (fun exp1 exp2 -> ebinop bop_neq exp1 exp2) -let pfeneq pfe = chainl1 pfe fneq -let fles = check_chunk "<" *> return (fun exp1 exp2 -> ebinop bop_les exp1 exp2) -let pfeles pfe = chainl1 pfe fles -let fleq = check_chunk "<=" *> return (fun exp1 exp2 -> ebinop bop_leq exp1 exp2) -let pfeleq pfe = chainl1 pfe fleq -let fgre = check_chunk ">" *> return (fun exp1 exp2 -> ebinop bop_gre exp1 exp2) -let pfegre pfe = chainl1 pfe fgre -let fgeq = check_chunk ">=" *> return (fun exp1 exp2 -> ebinop bop_geq exp1 exp2) -let pfegeq pfe = chainl1 pfe fgeq -let fand = check_chunk "&&" *> return (fun exp1 exp2 -> ebinop bop_and exp1 exp2) -let pfeand pfe = chainr1 pfe fand -let ffor = check_chunk "||" *> return (fun exp1 exp2 -> ebinop bop_or exp1 exp2) -let pfeor pfe = chainr1 pfe ffor -let fcons = check_chunk "::" *> return (fun exp1 exp2 -> ebinop bop_cons exp1 exp2) -let pfecons pfe = chainr1 pfe fcons - -let pfearith pfe = - let pfe = pfemul pfe <|> pfe in - let pfe = pfediv pfe <|> pfe in - let pfe = pfeadd pfe <|> pfe in - let pfe = pfesub pfe <|> pfe in - let pfe = pfecons pfe <|> pfe in - let pfe = pfeneq pfe <|> pfe in - let pfe = pfeeq pfe <|> pfe in - let pfe = pfeles pfe <|> pfe in - let pfe = pfeleq pfe <|> pfe in - let pfe = pfegre pfe <|> pfe in - let pfe = pfegeq pfe <|> pfe in - pfe -;; - -(* doc:https://v2.ocaml.org/manual/expr.html#ss:precedence-and-associativity *) -let pfexp = - fix - @@ fun pfexp -> - let pfe = pfebase pfexp in - let pfe = pfeapp pfe <|> pfe in - let pfe = pfearith pfe <|> pfe in - let pfe = pfeand pfe <|> pfe in - let pfe = pfeor pfe <|> pfe in - let pfe = pfeif pfe <|> pfe in - let pfe = check_chunk "fun" *> pfefun pfe <|> pfe in - let pfe = lift2 elet (pfelet pfe) (check_chunk "in" *> pfe) <|> pfe in - pfe -;; - -(* declaration parser *) - -let pdecl = - check_chunk "let" - *> lift4 - dlet - (drec <$> (check_chunk "rec" *> return true <|> return false)) - (lname <$> pvarname) - (dtype <$> (check_chunk ":" *> pftype <|> return temptytype)) - (check_chunk "=" *> pfexp) -;; - -let parse_program = many pdecl -let parse str = parse_string ~consume:All parse_program str - -let ptest str expected = - match parse str with - | Ok actual -> List.equal equal_decl expected actual - | Error err -> - printf "%s\n" err; - false -;; - -(* tests *) - -(* tests for declaration type parsing *) -let%test _ = - ptest - "let a : int -> (int -> string) -> int = \"a\"" - [ DLet - ( DRec false - , LName "a" - , DType (TFun (TInt, TFun (TFun (TInt, TString), TInt))) - , EString "a" ) - ] -;; - -let%test _ = - ptest - "let a : int list = \"a\"" - [ DLet (DRec false, LName "a", DType (TList TInt), EString "a") ] -;; - -let%test _ = - ptest - "let rec abc : ((int list) list) list = \"a\"" - [ DLet (DRec true, LName "abc", DType (TList (TList (TList TInt))), EString "a") ] -;; - -let%test _ = - ptest - "let rec abc : int -> (int -> (int -> int)) -> int = \"a\"" - [ DLet - ( DRec true - , LName "abc" - , DType (TFun (TInt, TFun (TFun (TInt, TFun (TInt, TInt)), TInt))) - , EString "a" ) - ] -;; - -let%test _ = - ptest - "let aBC: (string * int) list = \"a\"" - [ DLet (DRec false, LName "aBC", DType (TList (TTuple [ TString; TInt ])), EString "a") - ] -;; - -let%test _ = - ptest - "let aBC: (int list * (string -> int)) list = \"a\"" - [ DLet - ( DRec false - , LName "aBC" - , DType (TList (TTuple [ TList TInt; TFun (TString, TInt) ])) - , EString "a" ) - ] -;; - -let%test _ = - ptest - "let aBC: (int list * string * a) -> string list = \"a\"" - [ DLet - ( DRec false - , LName "aBC" - , DType (TFun (TTuple [ TList TInt; TString; TVar (LName "a") ], TList TString)) - , EString "a" ) - ] -;; - -let%test _ = - ptest - "let aBC: ((int list -> int) * string * (int * int)) -> string list = \"a\"" - [ DLet - ( DRec false - , LName "aBC" - , DType - (TFun - ( TTuple [ TFun (TList TInt, TInt); TString; TTuple [ TInt; TInt ] ] - , TList TString )) - , EString "a" ) - ] -;; - -(* tests for expression type parsing *) -let%test _ = - ptest - "let aBC: (int list) list = fun (a: string -> int) (b: string -> string) -> 5" - [ DLet - ( DRec false - , LName "aBC" - , DType (TList (TList TInt)) - , EFun - ( (LName "a", DType (TFun (TString, TInt))) - , EFun ((LName "b", DType (TFun (TString, TString))), EInt 5) ) ) - ] -;; - -let%test _ = - ptest - "let aBC: (int list) list = let b: string = 5 in 5" - [ DLet - ( DRec false - , LName "aBC" - , DType (TList (TList TInt)) - , ELet ((DRec false, LName "b", DType TString, EInt 5), EInt 5) ) - ] -;; - -let%test _ = - ptest - "let aBC: int -> int = let b: int -> int = fun (x: int) -> x in b" - [ DLet - ( DRec false - , LName "aBC" - , DType (TFun (TInt, TInt)) - , ELet - ( ( DRec false - , LName "b" - , DType (TFun (TInt, TInt)) - , EFun ((LName "x", DType TInt), EVar (LName "x")) ) - , EVar (LName "b") ) ) - ] -;; - -let%test _ = - ptest - "let aBC: int -> int = let b: int -> int = fun (x: int) -> (let summ: int = 5 in b) \ - in c" - [ DLet - ( DRec false - , LName "aBC" - , DType (TFun (TInt, TInt)) - , ELet - ( ( DRec false - , LName "b" - , DType (TFun (TInt, TInt)) - , EFun - ( (LName "x", DType TInt) - , ELet ((DRec false, LName "summ", DType TInt, EInt 5), EVar (LName "b")) - ) ) - , EVar (LName "c") ) ) - ] -;; - -let%test _ = - ptest - "let aBC: int = fun (n: int) -> if n then 5 else 0" - [ DLet - ( DRec false - , LName "aBC" - , DType TInt - , EFun ((LName "n", DType TInt), EIf (EVar (LName "n"), EInt 5, EInt 0)) ) - ] -;; - -let%test _ = - ptest - "let aBC: int = fun (n: int) -> if 2 - n * (1 - 1 * 3 + 1) then 5 else 0" - [ DLet - ( DRec false - , LName "aBC" - , DType TInt - , EFun - ( (LName "n", DType TInt) - , EIf - ( EBinop - ( Sub - , EInt 2 - , EBinop - ( Mul - , EVar (LName "n") - , EBinop - ( Sub - , EInt 1 - , EBinop (Add, EBinop (Mul, EInt 1, EInt 3), EInt 1) ) ) ) - , EInt 5 - , EInt 0 ) ) ) - ] -;; - -let%test _ = - ptest - "let aBC: int -> int = f n e" - [ DLet - ( DRec false - , LName "aBC" - , DType (TFun (TInt, TInt)) - , EApp (EApp (EVar (LName "f"), EVar (LName "n")), EVar (LName "e")) ) - ] -;; - -let%test _ = - ptest - "let x = fun (x: int) -> if true then if true then 1 else 2 else 3" - [ DLet - ( DRec false - , LName "x" - , DType TEmptyType - , EFun - ( (LName "x", DType TInt) - , EIf (EBool true, EIf (EBool true, EInt 1, EInt 2), EInt 3) ) ) - ] -;; - -(* test for factorial *) -let%test _ = - ptest - "let rec factorial_recursive = fun (n: int) -> if n <= 1 then 1 else n * \ - factorial_recursive (n - 1)" - [ DLet - ( DRec true - , LName "factorial_recursive" - , DType TEmptyType - , EFun - ( (LName "n", DType TInt) - , EIf - ( EBinop (Leq, EVar (LName "n"), EInt 1) - , EInt 1 - , EBinop - ( Mul - , EVar (LName "n") - , EApp - ( EVar (LName "factorial_recursive") - , EBinop (Sub, EVar (LName "n"), EInt 1) ) ) ) ) ) - ] -;; diff --git a/Ocaml+printf/.gitignore b/Ocaml+printf/.gitignore deleted file mode 100644 index 0d980ee1a..000000000 --- a/Ocaml+printf/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs -.vscode/ diff --git a/Ocaml+printf/.ocamlformat b/Ocaml+printf/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Ocaml+printf/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Ocaml+printf/COPYING b/Ocaml+printf/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Ocaml+printf/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Ocaml+printf/COPYING.CC0 b/Ocaml+printf/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Ocaml+printf/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Ocaml+printf/COPYING.LESSER b/Ocaml+printf/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Ocaml+printf/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Ocaml+printf/DONT_REMOVE_THIS_DIRECTORY.md b/Ocaml+printf/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Ocaml+printf/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Ocaml+printf/Makefile b/Ocaml+printf/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Ocaml+printf/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Ocaml+printf/Ocaml+printf.opam b/Ocaml+printf/Ocaml+printf.opam deleted file mode 100644 index 30d51889d..000000000 --- a/Ocaml+printf/Ocaml+printf.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for OCaml with printf" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc. - TODO" -maintainer: ["Demchenko Artem"] -authors: ["Demchenko Artem"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/aartdem/fp2023" -bug-reports: "https://github.com/aartdem/fp2023" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Ocaml+printf/README.md b/Ocaml+printf/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/Ocaml+printf/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Ocaml+printf/demos/demoInfer.ml b/Ocaml+printf/demos/demoInfer.ml deleted file mode 100644 index 7b5e6763f..000000000 --- a/Ocaml+printf/demos/demoInfer.ml +++ /dev/null @@ -1,16 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -let () = - let str = Stdio.In_channel.input_all Stdlib.stdin in - let parsed = Parser.run_parser_program str in - match parsed with - | Result.Error err -> Format.printf "Parsing error%s\n" err - | Result.Ok parsed -> - (match Inferencer.run_infer_program parsed with - | Ok (env, _) -> Format.printf "%a" Inferencer.TypeEnv.pp_env env - | Error err -> Format.printf "%a" Inferencer.pp_error err) -;; diff --git a/Ocaml+printf/demos/demoInfer.t b/Ocaml+printf/demos/demoInfer.t deleted file mode 100644 index d01a6538e..000000000 --- a/Ocaml+printf/demos/demoInfer.t +++ /dev/null @@ -1,42 +0,0 @@ - $ dune exec demoInfer << EOF - > let rec fac n = if n <= 1 then 1 else n * fac (n - 1) - > let sum x y = x + y - > let id x = x - > let f x = match id x with - > | a::b::c -> let s = sum a b in printf "%d" s; s - > | a::b -> printf "%d" a; fac a - > | [] -> printf "Achieved empty\n"; 1 - > EOF - val f : int list -> int - val fac : int -> int - val id : forall 'a. 'a -> 'a - val sum : int -> int -> int -PRINTF - $ dune exec demoInfer << EOF - > let my_printf = printf - > let fmt_printf = my_printf ("string: %s\n" ^^ format_of_string "int: %d\n");; - > fmt_printf "abcd" 123 - > EOF - val fmt_printf : string -> int -> unit - val my_printf : forall 'a. 'a format_string -> 'a -MORE EXAMPLES - $ dune exec demoInfer << EOF - > let fst (a, b) = a - > let snd (a, b) = b - > let tuple1 = (fst, snd, ('a',"bcd")) - > let tuple2 = let unpack (f1, f2, t) = (f1 t, f2 t) in unpack tuple1 - > EOF - val fst : forall 'a 'b. 'a * 'b -> 'a - val snd : forall 'a 'b. 'a * 'b -> 'b - val tuple1 : forall 'a 'b 'c 'd. ('a * 'b -> 'a) * ('c * 'd -> 'd) * (char * string) - val tuple2 : char * string -FACTORIAL WITH FIX - $ dune exec demoInfer << EOF - > let rec fix f x = f (fix f) x - > let fac = fix (fun self n -> if n <= 1 then 1 else n * self (n - 1)) - > let x = fac 1 - > let y = fac 10 - val fac : int -> int - val fix : forall 'a 'b. (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b - val x : int - val y : int diff --git a/Ocaml+printf/demos/demoInterpreter.ml b/Ocaml+printf/demos/demoInterpreter.ml deleted file mode 100644 index 1d15876be..000000000 --- a/Ocaml+printf/demos/demoInterpreter.ml +++ /dev/null @@ -1,36 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -let print_res typed_env env_values = - let open Interpreter in - let open Inferencer in - let std = EnvValues.std in - let without_std = - Base.Map.filter_keys env_values ~f:(fun name -> - match EnvValues.find std name with - | None -> true - | Some _ -> false) - in - Base.Map.iteri without_std ~f:(fun ~key ~data -> - match TypeEnv.find typed_env key with - | Some sch -> - Format.printf "val %s : %a = %a\n" key Pprint.pp_scheme_without sch pp_value data - | None -> Format.printf "Value %s is not in typed environment\n" key) -;; - -let () = - let str = Stdio.In_channel.input_all Stdlib.stdin in - let parsed = Parser.run_parser_program str in - match parsed with - | Result.Error err -> Format.printf "Parsing error%s\n" err - | Result.Ok parsed -> - (match Inferencer.run_infer_program parsed with - | Error err -> Format.printf "Type inference error. %a" Inferencer.pp_error err - | Ok (typed_env, new_ast) -> - (match Interpreter.run_eval_program new_ast with - | Error err -> Format.printf "Interpretation error. %a" Interpreter.pp_error err - | Ok env_values -> print_res typed_env env_values)) -;; diff --git a/Ocaml+printf/demos/demoInterpreter.t b/Ocaml+printf/demos/demoInterpreter.t deleted file mode 100644 index f7a909dae..000000000 --- a/Ocaml+printf/demos/demoInterpreter.t +++ /dev/null @@ -1,103 +0,0 @@ -FACTORIAL: - $ dune exec demoInterpreter << EOF - > let rec fac n = if n <= 1 then 1 else n * fac (n - 1) - > let x = fac 6 - > EOF - val fac : int -> int = - val x : int = 720 -FIBONACCI: - $ dune exec demoInterpreter << EOF - > let rec fib = fun n -> match n with - > | 0 -> 0 - > | 1 -> 1 - > | n -> fib (n - 1) + fib (n - 2) - > let x = fib 10 - > EOF - val fib : int -> int = - val x : int = 55 -REVERESE LIST: - $ dune exec demoInterpreter << EOF - > let rev list = - > let rec helper acc list = - > match list with - > | [] -> acc - > | h :: tl -> helper (h :: acc) tl - > in - > helper [] list - > let reversed1 = rev [1;2;3;4;5] - > let reversed2 = rev [true;false;false;false] - > EOF - val rev : 'a list -> 'a list = - val reversed1 : int list = [5; 4; 3; 2; 1] - val reversed2 : bool list = [false; false; false; true] -FORMAT STRINGS, PRINTF, ETC - $ dune exec demoInterpreter << EOF - > let fmt1 = format_of_string "int: %d, char: %c\n" - > let fmt1 = "string: %s, " ^^ fmt1 - > let fmt1 = format_of_string fmt1 - > let str = "abcdef";; - > printf fmt1 str (length str) str.[0] - > EOF - string: abcdef, int: 6, char: a - val fmt1 : string -> int -> char -> unit format_string = "string: %s, int: %d, char: %c\n" format - val str : string = "abcdef" -PRINTF - $ dune exec demoInterpreter << EOF - > let my_printf = printf ("%d\n%d" ^^ "\n%B %B\n");; - > my_printf 1 2 true false - > EOF - 1 - 2 - true false - val my_printf : int -> int -> bool -> bool -> unit = -TUPLES - $ dune exec demoInterpreter << EOF - > let result = - > let id x = x in - > let fst (a, _) = a in - > let snd (_, b) = b in - > let tuple = 1, (2, 3) in - > let x = id (fst (snd tuple)) in - > printf "%d %d\n" x (id x) - 2 2 - val result : unit = () -STRINGS, OPERATIONS - $ dune exec demoInterpreter << EOF - > let str = "abcde" ^ "str2" - > let partial = printf "%c %d\n" str.[7];; - > partial 8 - r 8 - val partial : int -> unit = - val str : string = "abcdestr2" -CONCATINATION STRING LIST AND PRINT STEPS - $ dune exec demoInterpreter << EOF - > let rec concat list = - > match list with - > | [] -> "" - > | h :: tl -> - > printf "%s\n" h; - > h ^ concat tl - > let s = concat [ "aaa"; "bb"; "c" ] - aaa - bb - c - val concat : string list -> string = - val s : string = "aaabbc" -SEVERAL_PRINTF - $ dune exec demoInterpreter << EOF - > printf "a1\n";; - > printf "b2\n";; - > printf "c3\n";; - a1 - b2 - c3 -FACTORIAL WITH FIX - $ dune exec demoInterpreter << EOF - > let rec fix f x = f (fix f) x - > let fac = fix (fun self n -> if n <= 1 then 1 else n * self (n - 1)) - > let x = fac 1 - > let y = fac 6 - val fac : int -> int = - val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = - val x : int = 1 - val y : int = 720 diff --git a/Ocaml+printf/demos/demoParse.ml b/Ocaml+printf/demos/demoParse.ml deleted file mode 100644 index db7f30e4b..000000000 --- a/Ocaml+printf/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Parser.run_parser_program s with - | Result.Ok ast -> Format.printf "%a\n" Ast.pp_program ast - | Error err -> Format.printf "Parsing error%s\n" err -;; diff --git a/Ocaml+printf/demos/demoParse.t b/Ocaml+printf/demos/demoParse.t deleted file mode 100644 index 33c34699c..000000000 --- a/Ocaml+printf/demos/demoParse.t +++ /dev/null @@ -1,27 +0,0 @@ - $ dune exec demoParse << EOF - > let rec fac n = if n <= 1 then 1 else n * fac (n - 1) - > let sum x y = x + y - > EOF - [(Let_decl - (true, (LCIdent "fac"), - (Expr_fun ((Pat_val (LCIdent "n")), - (Expr_ite ( - (Bin_op (Leq, (Expr_val (LCIdent "n")), (Expr_const (Int 1)))), - (Expr_const (Int 1)), - (Bin_op (Mul, (Expr_val (LCIdent "n")), - (Expr_app ((Expr_val (LCIdent "fac")), - (Bin_op (Sub, (Expr_val (LCIdent "n")), (Expr_const (Int 1)) - )) - )) - )) - )) - )))); - (Let_decl - (false, (LCIdent "sum"), - (Expr_fun ((Pat_val (LCIdent "x")), - (Expr_fun ((Pat_val (LCIdent "y")), - (Bin_op (Add, (Expr_val (LCIdent "x")), (Expr_val (LCIdent "y")) - )) - )) - )))) - ] diff --git a/Ocaml+printf/demos/dune b/Ocaml+printf/demos/dune deleted file mode 100644 index 7a2eacc3f..000000000 --- a/Ocaml+printf/demos/dune +++ /dev/null @@ -1,26 +0,0 @@ -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries ocaml_printf_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoInfer) - (modules demoInfer) - (public_name demoInfer) - (libraries ocaml_printf_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoInterpreter) - (modules demoInterpreter) - (public_name demoInterpreter) - (libraries ocaml_printf_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demoParse} %{bin:demoInfer} %{bin:demoInterpreter})) diff --git a/Ocaml+printf/dune-project b/Ocaml+printf/dune-project deleted file mode 100644 index fab2509aa..000000000 --- a/Ocaml+printf/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Demchenko Artem") - -(maintainers "Demchenko Artem") - -(bug_reports "https://github.com/aartdem/fp2023") - -(homepage "https://github.com/aartdem/fp2023") - -(package - (name Ocaml+printf) - (synopsis "An interpreter for OCaml with printf") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc. - TODO") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Ocaml+printf/lib/ast.ml b/Ocaml+printf/lib/ast.ml deleted file mode 100644 index 0fae647fd..000000000 --- a/Ocaml+printf/lib/ast.ml +++ /dev/null @@ -1,87 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type fmt_item = - | FmtInt (** "%d"*) - | FmtChar (** "%c" *) - | FmtString (** "%s" *) - | FmtBool (** "%B" *) - | SimpleStr of string (** format string without any specifications *) -[@@deriving show { with_path = false }] - -(** Empty list means empty string *) -type fstring = fmt_item list [@@deriving show { with_path = false }] - -type const = - | Int of int (** 1 *) - | Bool of bool (** true *) - | Char of char (** 'a' *) - | String of string (** "abc" *) -[@@deriving show { with_path = false }] - -type un_op = - | Un_plus (** + *) - | Un_minus (** - *) -[@@deriving show { with_path = false }] - -type bin_op = - | Add (** + *) - | Sub (** - *) - | Mul (** * *) - | Div (** / *) - | Eq (** = *) - | Neq (** <> *) - | Leq (** <= *) - | Geq (** >= *) - | Gre (** > *) - | Less (** < *) - | And (** && *) - | Or (** || *) - | Concat (** ^ *) - | Concat_format (** ^^ *) -[@@deriving show { with_path = false }] - -type val_name = LCIdent of string (** variable_name1 *) -[@@deriving show { with_path = false }] - -type pattern = - | Pat_any (** _ *) - | Pat_val of val_name (** abc *) - | Pat_const of const (** 1 *) - | Pat_tuple of pattern * pattern list (** (1, 2) *) - | Pat_cons_list of pattern * pattern (** 1::[] or [1;2] *) - | Pat_empty_list (** [] *) -[@@deriving show { with_path = false }] - -type expr = - | Expr_const of const (** 1 *) - | Un_op of un_op * expr (** -1 *) - | Bin_op of bin_op * expr * expr (** 2 + 2 *) - | Expr_val of val_name (** val1 *) - | Expr_ite of expr * expr * expr (** if a then b else c *) - | Expr_fun of pattern * expr (** fun x -> x + 1 *) - | Expr_app of expr * expr (** f x *) - | Expr_let of decl * expr (** let a = 1 in b *) - | Expr_match of expr * (pattern * expr) list (** match x with | 1 -> 0 | _ -> 1 *) - | Expr_empty_list (** [] *) - | Expr_cons_list of expr * expr (** 1::[] or [1;2] *) - | Expr_tuple of expr * expr list (** (1, a, 'c') *) - | Expr_seq of expr * expr (** e1; e2 *) - | Expr_fstring of fstring (*** "abc%d %c" *) - (* hard-coded functions *) - | Expr_printf (** printf "%c%d abc" *) - | Expr_formatted_printf of fstring (** printf "%c%d abc" 'c' 4 *) - | Expr_format_of_str (** format_of_string *) - | Expr_get (** str.[i] *) - | Expr_length (** length str *) -[@@deriving show { with_path = false }] - -and decl = bool * val_name * expr - -type toplevel = - | Let_decl of decl (** let a = 1 *) - | Expr of expr (** printf "abc" *) -[@@deriving show { with_path = false }] - -type program = toplevel list [@@deriving show { with_path = false }] diff --git a/Ocaml+printf/lib/dune b/Ocaml+printf/lib/dune deleted file mode 100644 index 653672aa6..000000000 --- a/Ocaml+printf/lib/dune +++ /dev/null @@ -1,27 +0,0 @@ -(include_subdirs unqualified) - -(library - (name ocaml_printf_lib) - (public_name Ocaml+printf.Lib) - (modules Ast Parser Typedtree Inferencer Interpreter Pprint) - (libraries base stdlib angstrom) - (inline_tests) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules Parser_tests Infer_tests Interpret_tests) - (libraries ocaml_printf_lib) - (inline_tests) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(env - (dev - (flags - (:standard -w -32)))) diff --git a/Ocaml+printf/lib/inferencer.ml b/Ocaml+printf/lib/inferencer.ml deleted file mode 100644 index 2b0314b01..000000000 --- a/Ocaml+printf/lib/inferencer.ml +++ /dev/null @@ -1,689 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Solution template was taken from - https://gitlab.com/Kakadu/fp2020course-materials/-/blob/master/code/miniml/inferencer.ml?ref_type=heads - Bug with generalize was fixed - Lists have been replaced with maps - Names have been changed in many places to increase readability *) - -open Typedtree - -type error = - [ `Occurs_check - | `No_variable of string - | `Unification_failed of typ * typ - | `Multiple_bound of string - | `Invalid_format_str of string - | `Ivalid_format_concat of typ * typ - | `Impossible_state of string - | `Unexpected_expr of Ast.expr - ] - -let pp_error ppf : error -> unit = function - | `Occurs_check -> Format.fprintf ppf {|Occurs check failed|} - | `No_variable s -> Format.fprintf ppf {|Undefined variable "%s"|} s - | `Unification_failed (l, r) -> - Format.fprintf ppf {|Unification failed on %a and %a|} Pprint.pp_typ l Pprint.pp_typ r - | `Multiple_bound s -> - Format.fprintf ppf {|Variable %s is bound several times in matching|} s - | `Invalid_format_str s -> Format.fprintf ppf {|Invalid format string "%s"|} s - | `Ivalid_format_concat (t1, t2) -> - Format.fprintf - ppf - {|Invalid format concatination of "%a" and "%a"|} - Pprint.pp_typ - t1 - Pprint.pp_typ - t2 - | `Impossible_state s -> - Format.fprintf ppf {|Impossible inference algorithm state: %s|} s - | `Unexpected_expr expr -> - Format.fprintf - ppf - {|Unexpected expression on type inference stage: %a|} - Ast.pp_expr - expr -;; - -module R : sig - type 'a t - - val return : 'a -> 'a t - val bind : 'a t -> ('a -> 'b t) -> 'b t - val fail : error -> 'a t - - include Base.Monad.Infix with type 'a t := 'a t - - module Syntax : sig - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t - end - - module RList : sig - val fold_left : 'a list -> init:'b t -> f:('b -> 'a -> 'b t) -> 'b t - val fold_right : 'a list -> init:'b t -> f:('a -> 'b -> 'b t) -> 'b t - end - - module RMap : sig - val fold : ('a, 'b, 'c) Base.Map.t -> init:'d t -> f:('d -> 'a -> 'b -> 'd t) -> 'd t - end - - (** Creation of a fresh name from internal state *) - val fresh : int t - - (** Running a transformer: getting the inner result value *) - val run : 'a t -> ('a, error) Base.Result.t -end = struct - open Base - - (* A compositon: State monad after Result monad *) - type 'a t = int -> int * ('a, error) Result.t - - let return x : 'a t = fun var -> var, Result.return x - let fail e : 'a t = fun var -> var, Result.fail e - let fresh : 'a t = fun var -> var + 1, Result.return var - - let ( >>= ) (m : 'a t) (f : 'a -> 'b t) : 'b t = - fun var -> - match m var with - | var, Result.Error err -> var, Result.fail err - | var, Result.Ok x -> f x var - ;; - - let bind x f = x >>= f - - let ( >>| ) (m : 'a t) (f : 'a -> 'b) : 'b t = - fun var -> - match m var with - | var, Result.Error err -> var, Result.fail err - | var, Result.Ok x -> var, Result.return (f x) - ;; - - module Syntax = struct - let ( let* ) x f = bind x f - end - - module RMap = struct - let fold mp ~init ~f = - let open Syntax in - Map.fold mp ~init ~f:(fun ~key:k ~data:v acc -> - let* acc = acc in - f acc k v) - ;; - end - - module RList = struct - let fold_left xs ~init ~f = - let open Syntax in - List.fold_left xs ~init ~f:(fun acc x -> - let* acc = acc in - f acc x) - ;; - - let fold_right xs ~init ~f = - let open Syntax in - List.fold_right xs ~init ~f:(fun x acc -> - let* acc = acc in - f x acc) - ;; - end - - (* 2 because we have two functions that accept typed variables (see below) *) - let run m = snd (m 2) -end - -module Type = struct - let rec occurs_in v = function - | TVar b -> b = v - | TArr (l, r) -> occurs_in v l || occurs_in v r - | TTuple (h, list) -> - List.fold_left (fun occurs item -> occurs || occurs_in v item) (occurs_in v h) list - | TList t -> occurs_in v t - | TFString t -> occurs_in v t - | _ -> false - ;; - - let type_vars = - let rec helper acc = function - | TVar b -> TypeVarSet.add b acc - | TArr (l, r) -> helper (helper acc l) r - | TTuple (h, list) -> - List.fold_left (fun acc item -> helper acc item) (helper acc h) list - | TList t -> helper acc t - | TFString t -> helper acc t - | _ -> acc - in - helper TypeVarSet.empty - ;; -end - -module Subst : sig - type t - - val empty : t - val singleton : int -> typ -> t R.t - val remove : t -> int -> t - val apply : t -> typ -> typ - val unify : typ -> typ -> t R.t - val pp_subst : Format.formatter -> t -> unit - - (** Compositon of substitutions *) - val compose : t -> t -> t R.t - - val compose_all : t list -> t R.t -end = struct - open R - open R.Syntax - open Base - - type t = (int, typ, Int.comparator_witness) Map.t - - let empty = Map.empty (module Int) - - let singleton k v = - if Type.occurs_in k v - then fail `Occurs_check - else return (Map.singleton (module Int) k v) - ;; - - let find mp ty = Map.find mp ty - let remove mp ty = Map.remove mp ty - - let apply sub = - let rec helper = function - | TVar tv as ty -> - (match find sub tv with - | None -> ty - | Some x -> x) - | TArr (l, r) -> TArr (helper l, helper r) - | TTuple (h, list) -> TTuple (helper h, List.map list ~f:(fun item -> helper item)) - | TList t -> TList (helper t) - | TFString t -> TFString (helper t) - | other -> other - in - helper - ;; - - let rec unify l r = - match l, r with - | TPrim l, TPrim r when String.equal l r -> return empty - | TVar a, TVar b when Int.equal a b -> return empty - | TVar b, t | t, TVar b -> singleton b t - | TArr (l1, r1), TArr (l2, r2) -> - let* sub1 = unify l1 l2 in - let* sub2 = unify (apply sub1 r1) (apply sub1 r2) in - compose sub1 sub2 - | TUnit, TUnit -> return empty - | TTuple (h1, list1), TTuple (h2, list2) -> - let* unified = - match List.map2 list1 list2 ~f:(fun t1 t2 -> unify t1 t2) with - | Unequal_lengths -> - fail (`Unification_failed (TTuple (h1, list1), TTuple (h2, list2))) - | Ok res -> return res - in - List.fold_left unified ~init:(unify h1 h2) ~f:(fun acc s -> - let* s = s in - let* acc = acc in - compose acc s) - | TList t1, TList t2 -> unify t1 t2 - | TFString t1, TFString t2 -> unify t1 t2 - | _ -> fail (`Unification_failed (l, r)) - - and extend sub typ_var ty = - match Map.find sub typ_var with - | None -> - let* new_sub = singleton typ_var (apply sub ty) in - let upd ~key ~data acc = - let* acc = acc in - let ty = apply new_sub data in - return (Map.update acc key ~f:(function _ -> ty)) - in - Map.fold sub ~init:(return new_sub) ~f:upd - | Some finded_type -> - let* sub2 = unify ty finded_type in - compose sub sub2 - - and compose s1 s2 = RMap.fold s2 ~init:(return s1) ~f:extend - - let compose_all ss = RList.fold_left ss ~init:(return empty) ~f:compose - - let pp_subst ppf sub = - Base.Map.iteri sub ~f:(fun ~key ~data -> - Stdlib.Format.fprintf ppf "[%d = %a] " key Pprint.pp_typ data) - ;; -end - -module Scheme = struct - let free_vars (Scheme (bind_set, t)) = TypeVarSet.diff (Type.type_vars t) bind_set - - let apply sub (Scheme (bind_set, ty)) = - let sub = TypeVarSet.fold (fun v s -> Subst.remove s v) bind_set sub in - Scheme (bind_set, Subst.apply sub ty) - ;; -end - -module TypeEnv : sig - type t - - val empty : t - val std : t - val update : t -> string -> scheme -> t - val remove : t -> string -> t - val free_vars : t -> TypeVarSet.t - val apply : Subst.t -> t -> t - val find : t -> string -> scheme option - val union : t -> t -> t - val pp_env : Format.formatter -> t -> unit -end = struct - open Base - - type t = (string, scheme, String.comparator_witness) Map.t - - (* overwrite existing *) - let update mp k v = Map.update mp k ~f:(function _ -> v) - let empty = Map.empty (module String) - - (** Environment with several supported functions with implementation and type are hard coded *) - let std = - let init_env = empty in - let init_env = - update init_env "length" (Scheme (TypeVarSet.empty, string_typ @-> int_typ)) - in - let init_env = - update - init_env - "get" - (Scheme (TypeVarSet.empty, string_typ @-> int_typ @-> char_typ)) - in - let init_env = - update - init_env - "printf" - (Scheme (TypeVarSet.singleton 0, format_typ (type_var 0) @-> type_var 0)) - in - let init_env = - update - init_env - "format_of_string" - (Scheme - (TypeVarSet.singleton 1, format_typ (type_var 1) @-> format_typ (type_var 1))) - in - init_env - ;; - - let free_vars env = - Map.fold env ~init:TypeVarSet.empty ~f:(fun ~key:_ ~data acc -> - TypeVarSet.union acc (Scheme.free_vars data)) - ;; - - let apply sub env = Map.map env ~f:(Scheme.apply sub) - let find mp k = Map.find mp k - let remove mp k = Map.remove mp k - - let union env1 env2 = - Map.fold env2 ~init:env1 ~f:(fun ~key ~data acc -> update acc key data) - ;; - - let pp_env ppf env = - Map.iteri env ~f:(fun ~key ~data -> - match find std key with - | None -> - Stdlib.Format.fprintf ppf "val %s : " key; - Pprint.pp_scheme_binder ppf data; - Stdlib.Format.fprintf ppf "\n" - | Some _ -> Stdlib.Format.fprintf ppf "") - ;; -end - -open R -open R.Syntax - -let fresh_var = fresh >>| fun n -> TVar n - -let instantiate (Scheme (bind_set, ty)) = - TypeVarSet.fold - (fun cur_var acc_typ -> - let* acc_typ = acc_typ in - let* f1 = fresh_var in - let* s = Subst.singleton cur_var f1 in - return (Subst.apply s acc_typ)) - bind_set - (return ty) -;; - -(* creating a scheme out of a type *) -let generalize env ty = - let free = TypeVarSet.diff (Type.type_vars ty) (TypeEnv.free_vars env) in - Scheme (free, ty) -;; - -(* add for recursion functions handling *) -let generalize_rec env ty exept = - let env = TypeEnv.remove env exept in - let free = TypeVarSet.diff (Type.type_vars ty) (TypeEnv.free_vars env) in - Scheme (free, ty) -;; - -let convert_to_format s : Ast.fstring option = - let open Ast in - let rec helper acc j = - match String.rindex_from_opt s j '%' with - | Some i when i < j -> - let str = String.sub s i (j - i + 1) in - let text = String.sub str 2 (j - i - 1) in - let type_spec = - match s.[i + 1] with - | 'd' -> Some FmtInt - | 'c' -> Some FmtChar - | 's' -> Some FmtString - | 'B' -> Some FmtBool - | _ -> None - in - (match type_spec with - | Some ty -> - let ty = if String.length text = 0 then [ ty ] else ty :: [ SimpleStr text ] in - if i > 0 then helper (List.append ty acc) (i - 1) else Some (List.append ty acc) - | None -> None) - | Some _ -> None - | None -> Some (SimpleStr (String.sub s 0 (j + 1)) :: acc) - in - if String.exists (fun c -> c = '%') s - then helper [] (String.length s - 1) - else Some [ Ast.SimpleStr s ] -;; - -let rec infer_format_type = function - | [] -> unit_typ - | h :: tl -> - (match h with - | Ast.FmtBool -> bool_typ @-> infer_format_type tl - | Ast.FmtInt -> int_typ @-> infer_format_type tl - | Ast.FmtChar -> char_typ @-> infer_format_type tl - | Ast.FmtString -> string_typ @-> infer_format_type tl - | Ast.SimpleStr _ -> infer_format_type tl) -;; - -let infer_format_concat fstring1 fstring2 = - let rec helper = function - | TUnit -> return fstring2 - | TArr (TPrim s, r) -> - let* r = helper r in - return @@ TPrim s @-> r - | _ -> fail @@ `Impossible_state "Try to concatination invalid format strings" - in - let* res = helper fstring1 in - return @@ format_typ res -;; - -let infer_const = function - | Ast.Int _ -> int_typ - | Ast.Bool _ -> bool_typ - | Ast.Char _ -> char_typ - | Ast.String _ -> string_typ -;; - -(* inference type of pattern and extend environment with values names *) -let rec infer_pattern env = function - | Ast.Pat_val (Ast.LCIdent name) -> - let* fresh = fresh_var in - (match TypeEnv.find env name with - | Some _ -> fail (`Multiple_bound name) - | None -> - let sheme = Scheme (TypeVarSet.empty, fresh) in - let env = TypeEnv.update env name sheme in - return (Subst.empty, fresh, env)) - | Ast.Pat_any -> - let* fresh = fresh_var in - return (Subst.empty, fresh, env) - | Ast.Pat_const c -> - let fresh = infer_const c in - return (Subst.empty, fresh, env) - | Ast.Pat_empty_list -> - let* fresh = fresh_var in - let fresh = TList fresh in - return (Subst.empty, fresh, env) - | Ast.Pat_cons_list (l1, r1) -> - let* sub1, typ1, env1 = infer_pattern env l1 in - let* sub2, typ2, env2 = infer_pattern (TypeEnv.apply sub1 env1) r1 in - let* fresh = fresh_var in - let* sub_uni = Subst.unify typ2 (TList fresh) in - let typ2 = Subst.apply sub_uni typ2 in - let* sub3 = Subst.unify (TList typ1) typ2 in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3; sub_uni ] in - return (final_sub, Subst.apply sub3 typ2, env2) - | Ast.Pat_tuple (h, list) -> - let* sub1, typ1, env1 = infer_pattern env h in - let f1 pat (sub_prev, l, env) = - let* sub_cur, arg, env = infer_pattern env pat in - let* sub = Subst.compose sub_prev sub_cur in - return (sub, arg :: l, env) - in - let* sub, arg, env = RList.fold_right list ~init:(return (sub1, [], env1)) ~f:f1 in - return (sub, TTuple (typ1, arg), env) -;; - -(*in addition to type inference, modifying AST by converting - some string literals to formatted strings in certan places *) -let rec infer_expr env expr = - let open Ast in - match expr with - | Expr_const c -> - let ty = infer_const c in - return (Subst.empty, ty, expr) - | Expr_empty_list -> - let* ty = fresh_var in - return (Subst.empty, TList ty, expr) - | Expr_val (LCIdent name) -> - (match TypeEnv.find env name with - | Some scheme -> - let* ans = instantiate scheme in - return (Subst.empty, ans, expr) - | None -> fail @@ `No_variable name) - | Un_op (_, e) -> - let* return_type = fresh_var in - let* sub1, typ1, expr = infer_expr env e in - let* sub2 = Subst.unify (TArr (typ1, return_type)) int_typ in - let* final_sub = Subst.compose sub1 sub2 in - return (final_sub, Subst.apply sub2 return_type, expr) - | Bin_op (op, e1, e2) -> infer_bin_op env op e1 e2 - | Expr_fun (pattern, e) -> - let* sub1, typ1, new_env = infer_pattern TypeEnv.empty pattern in - let env = TypeEnv.union env new_env in - let* sub2, typ2, expr = infer_expr (TypeEnv.apply sub1 env) e in - let arg_type = Subst.apply sub2 typ1 in - let* final_sub = Subst.compose sub1 sub2 in - return (final_sub, arg_type @-> typ2, Expr_fun (pattern, expr)) - | Expr_app (e1, e2) -> infer_app env e1 e2 - | Expr_let ((false, LCIdent name, e1), e2) -> - let* sub1, typ1, expr1 = infer_expr env e1 in - let env = TypeEnv.apply sub1 env in - let gen_scheme = generalize env typ1 in - let env = TypeEnv.update env name gen_scheme in - let* sub2, typ2, expr2 = infer_expr env e2 in - let* final_sub = Subst.compose sub1 sub2 in - return (final_sub, typ2, Expr_let ((false, LCIdent name, expr1), expr2)) - | Expr_let ((true, LCIdent name, e1), e2) -> - let* ty = fresh_var in - let env = TypeEnv.update env name (Scheme (TypeVarSet.empty, ty)) in - let* sub1, typ1, expr1 = infer_expr env e1 in - let* sub2 = Subst.unify typ1 ty in - let* sub3 = Subst.compose sub1 sub2 in - let env = TypeEnv.apply sub3 env in - let typ1 = Subst.apply sub3 typ1 in - let gen_scheme = generalize_rec env typ1 name in - let env = TypeEnv.update env name gen_scheme in - let* sub4, typ2, expr2 = infer_expr env e2 in - let* final_sub = Subst.compose sub3 sub4 in - return (final_sub, typ2, Expr_let ((true, LCIdent name, expr1), expr2)) - | Expr_ite (e1, e2, e3) -> - let* sub1, typ1, expr1 = infer_expr env e1 in - let* sub2, typ2, expr2 = infer_expr (TypeEnv.apply sub1 env) e2 in - let* sub3, typ3, expr3 = infer_expr (TypeEnv.apply sub2 env) e3 in - let* sub_cond = Subst.unify typ1 bool_typ in - let* sub_branches = Subst.unify typ2 typ3 in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3; sub_cond; sub_branches ] in - return (final_sub, Subst.apply sub_branches typ2, Expr_ite (expr1, expr2, expr3)) - | Expr_tuple (expr1, list) -> - let* sub1, typ1, expr1 = infer_expr env expr1 in - let env = TypeEnv.apply sub1 env in - let f1 prev cur_expr = - let* prev_env, prev_subst, prev_typ, prev_expr = prev in - let* cur_subst, cur_typ, cur_expr = infer_expr prev_env cur_expr in - let* next_subst = Subst.compose prev_subst cur_subst in - let next_env = TypeEnv.apply next_subst prev_env in - return (next_env, next_subst, cur_typ :: prev_typ, cur_expr :: prev_expr) - in - let* _, final_sub, typ_list, expr_list = - List.fold_left f1 (return (env, sub1, [], [])) list - in - let typ_list = - List.map (fun item -> Subst.apply final_sub item) (List.rev typ_list) - in - let expr_list = List.rev expr_list in - return - ( final_sub - , TTuple (Subst.apply final_sub typ1, typ_list) - , Expr_tuple (expr1, expr_list) ) - | Expr_cons_list (e1, e2) -> - let* sub1, typ1, expr1 = infer_expr env e1 in - let* sub2, typ2, expr2 = infer_expr (TypeEnv.apply sub1 env) e2 in - let* sub3 = Subst.unify (TList typ1) typ2 in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3 ] in - return (final_sub, Subst.apply sub3 typ2, Expr_cons_list (expr1, expr2)) - | Expr_match (e, list) -> - let* sub, arg_typ, e = infer_expr env e in - let* ret_typ = fresh_var in - let env = TypeEnv.apply sub env in - let f1 (cur_pat, cur_expr) (last_sub, last_pat_typ, last_ret_typ, pat_expr_list) = - let* last_sub = last_sub in - let* cur_sub, cur_arg_typ, new_env = infer_pattern TypeEnv.empty cur_pat in - let env = TypeEnv.union env new_env in - let* sub_ret, cur_ret_typ, cur_expr = - infer_expr (TypeEnv.apply cur_sub env) cur_expr - in - let cur_arg_typ = Subst.apply sub_ret cur_arg_typ in - let* sub_uni1 = Subst.unify cur_arg_typ last_pat_typ in - let* sub_uni2 = Subst.unify cur_ret_typ last_ret_typ in - return - ( Subst.compose_all [ last_sub; cur_sub; sub_ret; sub_uni1; sub_uni2 ] - , Subst.apply sub_uni1 cur_arg_typ - , Subst.apply sub_uni2 cur_ret_typ - , (cur_pat, cur_expr) :: pat_expr_list ) - in - let* sub, _, ret_typ, pat_expr_list = - RList.fold_right list ~init:(return (return sub, arg_typ, ret_typ, [])) ~f:f1 - in - let* sub = sub in - return (sub, Subst.apply sub ret_typ, Expr_match (e, pat_expr_list)) - | Expr_seq (e1, e2) -> - let* sub1, typ1, expr1 = infer_expr env e1 in - let* sub2 = Subst.unify typ1 unit_typ in - let* sub3, typ2, expr2 = infer_expr env e2 in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3 ] in - return (final_sub, typ2, Expr_seq (expr1, expr2)) - | expr -> fail @@ `Unexpected_expr expr - -and infer_bin_op env op e1 e2 = - let open Ast in - let* return_type = fresh_var in - let* sub1, typ1, expr1 = - match op, e1 with - (* first case when we need to convert string literal *) - | Concat_format, Expr_const (String s1) -> - (match convert_to_format s1 with - | Some fmt_s1 -> - return - @@ (Subst.empty, format_typ (infer_format_type fmt_s1), Expr_fstring fmt_s1) - | None -> fail @@ `Invalid_format_str s1) - | _ -> infer_expr env e1 - in - let* sub2, typ2, expr2 = - match op, e2 with - (* second case when we need to convert string literal *) - | Concat_format, Expr_const (String s2) -> - (match convert_to_format s2 with - | Some fmt_s2 -> - return (Subst.empty, format_typ (infer_format_type fmt_s2), Expr_fstring fmt_s2) - | None -> fail @@ `Invalid_format_str s2) - | _ -> infer_expr (TypeEnv.apply sub1 env) e2 - in - let* op_typ = - match op with - | Add | Sub | Mul | Div -> return (int_typ @-> int_typ @-> int_typ) - | Eq | Neq | Leq | Geq | Gre | Less -> return (int_typ @-> int_typ @-> bool_typ) - | And | Or -> return (bool_typ @-> bool_typ @-> bool_typ) - | Concat -> return (string_typ @-> string_typ @-> string_typ) - | Concat_format -> - (match typ1, typ2 with - | TFString fmt_s1, TFString fmt_s2 -> - let* res_typ = infer_format_concat fmt_s1 fmt_s2 in - return (format_typ fmt_s1 @-> format_typ fmt_s2 @-> res_typ) - | _ -> fail @@ `Ivalid_format_concat (typ1, typ2)) - in - let* sub3 = Subst.unify (typ1 @-> typ2 @-> return_type) op_typ in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3 ] in - return (final_sub, Subst.apply sub3 return_type, Bin_op (op, expr1, expr2)) - -and infer_app env e1 e2 = - let open Ast in - let* return_type = fresh_var in - let* sub1, typ1, expr1 = infer_expr env e1 in - let* sub2, typ2, expr2 = - match typ1, e2 with - (* case of applying function that expects format string as argument, - need to convert when argument is string literal *) - | TArr (TFString _, _), Expr_const (String s) -> - let fmt_s = convert_to_format s in - (match fmt_s with - | None -> fail @@ `Invalid_format_str s - | Some fmt_s -> - let ty = format_typ (infer_format_type fmt_s) in - return (Subst.empty, ty, Expr_fstring fmt_s)) - | _, e2 -> infer_expr (TypeEnv.apply sub1 env) e2 - in - let typ1 = Subst.apply sub2 typ1 in - let* sub3 = Subst.unify typ1 (typ2 @-> return_type) in - let* final_sub = Subst.compose_all [ sub1; sub2; sub3 ] in - return (final_sub, Subst.apply sub3 return_type, Expr_app (expr1, expr2)) -;; - -let infer_toplevel env = function - | Ast.Let_decl (false, Ast.LCIdent name, expr) -> - let* sub, ty, expr = infer_expr env expr in - let env = TypeEnv.apply sub env in - let gen_scheme = generalize env ty in - let env = TypeEnv.update env name gen_scheme in - return (env, ty, Ast.Let_decl (false, Ast.LCIdent name, expr)) - | Ast.Let_decl (true, Ast.LCIdent name, expr) -> - let* ty = fresh_var in - let env = TypeEnv.update env name (Scheme (TypeVarSet.empty, ty)) in - let* sub1, typ1, expr = infer_expr env expr in - let* sub2 = Subst.unify typ1 ty in - let* sub3 = Subst.compose sub1 sub2 in - let env = TypeEnv.apply sub3 env in - let typ1 = Subst.apply sub3 typ1 in - let gen_scheme = generalize_rec env typ1 name in - let env = TypeEnv.update env name gen_scheme in - return (env, Subst.apply sub2 typ1, Ast.Let_decl (true, Ast.LCIdent name, expr)) - | Ast.Expr expr -> - let* _, ty, expr = infer_expr env expr in - return (env, ty, Ast.Expr expr) -;; - -let infer_program prog = - let rec helper env = function - | [] -> return (env, []) - | h :: tl -> - let* new_env, _, new_ast = infer_toplevel env h in - let* env, ast_list = helper new_env tl in - return (env, new_ast :: ast_list) - in - helper TypeEnv.std prog -;; - -let run_infer_expr e = - Result.map (fun (_, ty, ast) -> ty, ast) (run (infer_expr TypeEnv.std e)) -;; - -let run_infer_program p = run (infer_program p) diff --git a/Ocaml+printf/lib/inferencer.mli b/Ocaml+printf/lib/inferencer.mli deleted file mode 100644 index 636bb0353..000000000 --- a/Ocaml+printf/lib/inferencer.mli +++ /dev/null @@ -1,27 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = - [ `Impossible_state of string - | `Invalid_format_str of string - | `Ivalid_format_concat of Typedtree.typ * Typedtree.typ - | `Multiple_bound of string - | `No_variable of string - | `Occurs_check - | `Unification_failed of Typedtree.typ * Typedtree.typ - | `Unexpected_expr of Ast.expr - ] - -val pp_error : Format.formatter -> error -> unit - -module TypeEnv : sig - type t - - val std : t - val find : t -> string -> Typedtree.scheme option - val pp_env : Format.formatter -> t -> unit -end - -val run_infer_expr : Ast.expr -> (Typedtree.typ * Ast.expr, error) result -val run_infer_program : Ast.program -> (TypeEnv.t * Ast.program, error) result diff --git a/Ocaml+printf/lib/interpreter.ml b/Ocaml+printf/lib/interpreter.ml deleted file mode 100644 index d6bdad18c..000000000 --- a/Ocaml+printf/lib/interpreter.ml +++ /dev/null @@ -1,451 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -let rec convert_to_string = function - | [] -> "" - | h :: tl -> - (match h with - | Ast.FmtInt -> "%d" ^ convert_to_string tl - | Ast.FmtBool -> "%B" ^ convert_to_string tl - | Ast.FmtChar -> "%c" ^ convert_to_string tl - | Ast.FmtString -> "%s" ^ convert_to_string tl - | Ast.SimpleStr str -> str ^ convert_to_string tl) -;; - -(* this printing method is purely for convenience *) -let pp_fstring ppf fstring = Format.fprintf ppf {|%S format|} (convert_to_string fstring) - -type value = - | VUnit - | VInt of int - | VBool of bool - | VChar of char - | VString of string - | VFormat_string of Ast.fstring - (** string option is None when function is non-recursive - and Some _ when function is recursive *) - | VFun of string option * Ast.pattern * Ast.expr * env_values - | VTuple of value * value list - | VList of value list - -and env_values = (string, value, Base.String.comparator_witness) Base.Map.t - -let rec pp_value ppf = function - | VUnit -> Format.fprintf ppf "()" - | VInt i -> Format.fprintf ppf "%d" i - | VBool b -> Format.fprintf ppf "%B" b - | VChar c -> Format.fprintf ppf {|%C|} c - | VString s -> Format.fprintf ppf {|%S|} s - | VFun _ -> Format.fprintf ppf "" - | VTuple (h, list) -> - Format.fprintf ppf "("; - let rec helper = function - | [] -> Format.fprintf ppf ")" - | h :: tl -> - let fmt = - match tl with - | [] -> format_of_string "%a" - | _ -> format_of_string "%a, " - in - Format.fprintf ppf fmt pp_value h; - helper tl - in - helper (h :: list) - | VList list -> - Format.fprintf ppf "["; - let rec helper = function - | [] -> Format.fprintf ppf "]" - | h :: tl -> - let fmt = - match tl with - | [] -> format_of_string "%a" - | _ -> format_of_string "%a; " - in - Format.fprintf ppf fmt pp_value h; - helper tl - in - helper list - (*TODO: maybe change *) - | VFormat_string t -> Format.fprintf ppf "%a" pp_fstring t -;; - -type error = - [ `Division_by_zero - | `Matching_failure - | `Invalid_argument of string - | `Type_mismatch (* unreachable after type check *) - | `No_variable (* unreachable after type check *) - | `Impossible_state of string (* unreachable *) - ] - -let pp_error ppf : error -> unit = function - | `Division_by_zero -> Format.fprintf ppf {|Division by zero|} - | `Invalid_argument s -> Format.fprintf ppf {|Invalid argument: %s|} s - | `Matching_failure -> Format.fprintf ppf {|Matching failure|} - | `Impossible_state s -> Format.fprintf ppf {|Impossible interpreter state: %s|} s - | `No_variable -> Format.fprintf ppf {|Undefined variable|} - | `Type_mismatch -> Format.fprintf ppf {|Type mismatch|} -;; - -module MONAD_WRITE_ERROR : sig - type 'a t - - val return : 'a -> 'a t - val bind : 'a t -> ('a -> 'b t) -> 'b t - val write : string -> unit t - val fail : error -> 'a t - val run : 'a t -> string * ('a, error) Base.Result.t - - include Base.Monad.Infix with type 'a t := 'a t - - module Syntax : sig - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t - end -end = struct - open Base - - type 'a t = string -> string * ('a, error) Result.t - - let return x : 'a t = fun str -> str, Result.return x - let write new_str : unit t = fun str -> str ^ new_str, Result.return () - let fail err : 'a t = fun str -> str, Result.fail err - - let ( >>= ) (m : 'a t) (f : 'a -> 'b t) : 'b t = - fun str -> - match m str with - | str, Result.Error e -> str, Result.fail e - | str, Result.Ok x -> f x str - ;; - - let ( >>| ) (m : 'a t) (f : 'a -> 'b) : 'b t = - fun str -> - match m str with - | str, Result.Error e -> str, Result.fail e - | str, Result.Ok x -> str, Result.return (f x) - ;; - - let bind x f = x >>= f - let run m = m "" - - module Syntax = struct - let ( let* ) x f = bind x f - end -end - -module EnvValues : sig - val std : env_values - val empty : env_values - val find : env_values -> string -> value option - val update : env_values -> string -> value -> env_values - val pp_env_values : Stdlib.Format.formatter -> env_values -> unit -end = struct - open Base - - let empty = Map.empty (module String) - let find mp key = Map.find mp key - let update mp key data = Map.update mp key ~f:(function _ -> data) - - let std = - let open Ast in - let val_length = VFun (None, Pat_val (LCIdent "s"), Expr_length, empty) in - let val_get = - VFun (None, Pat_val (LCIdent "s"), Expr_fun (Pat_val (LCIdent "i"), Expr_get), empty) - in - let val_format_of_str = - VFun (None, Pat_val (LCIdent "s"), Expr_format_of_str, empty) - in - let val_printf = VFun (None, Pat_val (LCIdent "fmt"), Expr_printf, empty) in - let init_env = empty in - let init_env = update init_env "length" val_length in - let init_env = update init_env "get" val_get in - let init_env = update init_env "format_of_string" val_format_of_str in - let init_env = update init_env "printf" val_printf in - init_env - ;; - - let pp_env_values ppf env_values = - Map.iteri env_values ~f:(fun ~key ~data -> - match find std key with - | None -> - Stdlib.Format.fprintf ppf "val %s = " key; - pp_value ppf data; - Stdlib.Format.fprintf ppf "\n" - | Some _ -> Stdlib.Format.fprintf ppf "") - ;; -end - -open MONAD_WRITE_ERROR -open MONAD_WRITE_ERROR.Syntax - -let rec match_pattern env = function - | Ast.Pat_any, _ -> Some env - | Ast.Pat_empty_list, VList [] -> Some env - | Ast.Pat_const (Int i1), VInt i2 when i1 = i2 -> Some env - | Ast.Pat_const (Bool b1), VBool b2 when b1 = b2 -> Some env - | Ast.Pat_const (Char c1), VChar c2 when c1 = c2 -> Some env - | Ast.Pat_const (String s1), VString s2 when s1 = s2 -> Some env - | Ast.Pat_val (LCIdent name), v -> Some (EnvValues.update env name v) - | Ast.Pat_tuple (pat1, pat_list), VTuple (v1, val_tuple) -> - let f1 env p v = - match env with - | Some env -> match_pattern env (p, v) - | None -> None - in - List.fold_left2 f1 (match_pattern env (pat1, v1)) pat_list val_tuple - | Ast.Pat_cons_list (p1, p2), VList (h :: tl) -> - (match match_pattern env (p1, h) with - | Some env -> match_pattern env (p2, VList tl) - | None -> None) - | _ -> None -;; - -let return_int i = return (VInt i) -let return_bool b = return (VBool b) -let return_char c = return (VChar c) -let return_string s = return (VString s) - -let eval_binop p v1 v2 = - let open Ast in - match p, v1, v2 with - | Add, VInt i1, VInt i2 -> return_int (i1 + i2) - | Sub, VInt i1, VInt i2 -> return_int (i1 - i2) - | Mul, VInt i1, VInt i2 -> return_int (i1 * i2) - | Div, VInt i1, VInt i2 -> - if i2 = 0 then fail `Division_by_zero else return_int (i1 / i2) - | Eq, VInt i1, VInt i2 -> return_bool (i1 = i2) - | Neq, VInt i1, VInt i2 -> return_bool (i1 <> i2) - | Leq, VInt i1, VInt i2 -> return_bool (i1 <= i2) - | Geq, VInt i1, VInt i2 -> return_bool (i1 >= i2) - | Gre, VInt i1, VInt i2 -> return_bool (i1 > i2) - | Less, VInt i1, VInt i2 -> return_bool (i1 < i2) - | And, VBool b1, VBool b2 -> return_bool (b1 && b2) - | Or, VBool b1, VBool b2 -> return_bool (b1 || b2) - | Concat, VString s1, VString s2 -> return_string (s1 ^ s2) - | Concat_format, VFormat_string s1, VFormat_string s2 -> - return (VFormat_string (List.append s1 s2)) - | _, _, _ -> fail `Type_mismatch -;; - -let eval_printf env = - let open Ast in - let* fmt = - match EnvValues.find env "fmt" with - | Some (VFormat_string fmt) -> return fmt - | _ -> fail `No_variable - in - let rec gen_body num = function - | [] -> Expr_formatted_printf fmt - | h :: tl -> - (match h with - | FmtInt | FmtChar | FmtString | FmtBool -> - Expr_fun (Pat_val (LCIdent ("arg" ^ Int.to_string num)), gen_body (num + 1) tl) - | SimpleStr _ -> gen_body num tl) - in - match gen_body 1 fmt with - | Expr_formatted_printf fmt -> - let* () = write (convert_to_string fmt) in - return VUnit - | Expr_fun (pat, expr) -> return @@ VFun (None, pat, expr, EnvValues.empty) - | _ -> fail @@ `Impossible_state "gen_body returns wrong value" -;; - -let eval_formatted_printf env fmt = - let open Ast in - let rec helper num = function - | [] -> return "" - | h :: tl -> - let arg = "arg" ^ Int.to_string num in - let value = EnvValues.find env arg in - let* s1, new_num = - match h, value with - | FmtInt, Some (VInt i) -> return (Int.to_string i, num + 1) - | FmtBool, Some (VBool b) -> return (Bool.to_string b, num + 1) - | FmtChar, Some (VChar c) -> return (Base.Char.to_string c, num + 1) - | FmtString, Some (VString s) -> return (s, num + 1) - | SimpleStr s, _ -> return (s, num) - | _, _ -> fail @@ `No_variable - in - let* s2 = helper new_num tl in - return (s1 ^ s2) - in - let* s = helper 1 fmt in - let* () = write s in - return VUnit -;; - -let eval_get env = - let s = EnvValues.find env "s" in - let i = EnvValues.find env "i" in - match s, i with - | Some (VString s), Some (VInt i) -> - if i < String.length s - then return @@ VChar s.[i] - else fail @@ `Invalid_argument "Index out of bounds" - | _, _ -> fail `No_variable -;; - -let eval_length env = - let s = EnvValues.find env "s" in - match s with - | Some (VString s) -> return @@ VInt (String.length s) - | _ -> fail `No_variable -;; - -let eval_expr = - let open Ast in - let rec helper env = function - | Expr_const e -> - (match e with - | Int i -> return_int i - | Bool b -> return_bool b - | Char c -> return_char c - | String s -> return_string s) - | Expr_val (LCIdent name) -> - (match EnvValues.find env name with - | Some x -> return x - | None -> fail `No_variable) - | Expr_empty_list -> return @@ VList [] - | Expr_fstring fmt -> return @@ VFormat_string fmt - | Un_op (op, e) -> - let* v = helper env e in - (match op, v with - | Un_plus, VInt i -> return_int i - | Un_minus, VInt i -> return_int (-i) - | _, _ -> fail `Type_mismatch) - | Bin_op (op, e1, e2) -> - let* e1 = helper env e1 in - let* e2 = helper env e2 in - eval_binop op e1 e2 - | Expr_ite (e1, e2, e3) -> - let* e1 = helper env e1 in - (match e1 with - | VBool true -> - let* e2 = helper env e2 in - return e2 - | VBool false -> - let* e3 = helper env e3 in - return e3 - | _ -> fail `Type_mismatch) - | Expr_let ((false, LCIdent name, e1), e2) -> - let* v1 = helper env e1 in - let env = EnvValues.update env name v1 in - let* v2 = helper env e2 in - return v2 - | Expr_let ((true, LCIdent name, e1), e2) -> - let* v1 = helper env e1 in - let v1 = - match v1 with - | VFun (None, p, e, env) -> VFun (Some name, p, e, env) - | other -> other - in - let env = EnvValues.update env name v1 in - let* v2 = helper env e2 in - return v2 - | Expr_fun (p, e) -> return (VFun (None, p, e, env)) - | Expr_app (e1, e2) -> - let* f = helper env e1 in - let* arg = helper env e2 in - (match f with - | VFun (fun_name, pat, e, fun_env) -> - let* new_env = - match match_pattern fun_env (pat, arg) with - | Some env -> return env - | None -> fail @@ `Matching_failure - in - let new_env = - match fun_name with - | Some fun_name -> EnvValues.update new_env fun_name f - | None -> new_env - in - helper new_env e - | _ -> fail `Type_mismatch) - | Expr_tuple (h, list) -> - let* value1 = helper env h in - let* value_list = - List.fold_left - (fun acc expr -> - let* acc = acc in - let* value = helper env expr in - return (value :: acc)) - (return []) - list - in - return @@ VTuple (value1, List.rev value_list) - | Expr_cons_list (h, tl) -> - let* h = helper env h in - let* tl = helper env tl in - (match tl with - | VList tl -> return @@ VList (h :: tl) - | _ -> fail `Type_mismatch) - | Expr_match (e, list) -> - let* v = helper env e in - eval_match env v list - | Expr_seq (e1, e2) -> - let* _ = helper env e1 in - let* v2 = helper env e2 in - return v2 - (* below are the functions with hardcoded implementation *) - | Expr_format_of_str -> - let s = EnvValues.find env "s" in - (match s with - | Some (VFormat_string s) -> return @@ VFormat_string s - | _ -> fail `No_variable) - | Expr_get -> eval_get env - | Expr_length -> eval_length env - | Expr_printf -> eval_printf env - | Expr_formatted_printf fstring -> eval_formatted_printf env fstring - and eval_match env v = function - | [] -> fail `Matching_failure - | (pat, expr) :: tl -> - let new_env = match_pattern env (pat, v) in - (match new_env with - | Some env -> helper env expr - | None -> eval_match env v tl) - in - helper -;; - -let eval_toplevel env = function - | Ast.Let_decl (false, Ast.LCIdent name, expr) -> - let* v = eval_expr env expr in - let env = EnvValues.update env name v in - return (env, v) - | Ast.Let_decl (true, Ast.LCIdent name, expr) -> - let* v = eval_expr env expr in - let v = - match v with - | VFun (None, p, e, env) -> VFun (Some name, p, e, env) - | other -> other - in - let env = EnvValues.update env name v in - return (env, v) - | Ast.Expr expr -> - let* v = eval_expr env expr in - return (env, v) -;; - -let eval_program prog = - List.fold_left - (fun acc toplevel -> - let* acc = acc in - let* env, _ = eval_toplevel acc toplevel in - return env) - (return EnvValues.std) - prog -;; - -let run_eval_program prog = - let out, env = run (eval_program prog) in - Format.printf "%s" out; - env -;; - -(* it is mainly used for tests *) -let run_eval_expr expr = - let out, value = run (eval_expr EnvValues.std expr) in - Format.printf "%s" out; - value -;; - -(* TODO: remove tests *) diff --git a/Ocaml+printf/lib/interpreter.mli b/Ocaml+printf/lib/interpreter.mli deleted file mode 100644 index 73ce2eac8..000000000 --- a/Ocaml+printf/lib/interpreter.mli +++ /dev/null @@ -1,38 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type value = - | VUnit - | VInt of int - | VBool of bool - | VChar of char - | VString of string - | VFormat_string of Ast.fstring - | VFun of string option * Ast.pattern * Ast.expr * env_values - | VTuple of value * value list - | VList of value list - -and env_values = (string, value, Base.String.comparator_witness) Base.Map.t - -val pp_value : Format.formatter -> value -> unit - -type error = - [ `Division_by_zero - | `Impossible_state of string - | `Invalid_argument of string - | `Matching_failure - | `No_variable - | `Type_mismatch - ] - -val pp_error : Format.formatter -> error -> unit - -module EnvValues : sig - val std : env_values - val find : env_values -> string -> value option - val pp_env_values : Stdlib.Format.formatter -> env_values -> unit -end - -val run_eval_program : Ast.toplevel list -> (env_values, error) result -val run_eval_expr : Ast.expr -> (value, error) result diff --git a/Ocaml+printf/lib/parser.ml b/Ocaml+printf/lib/parser.ml deleted file mode 100644 index f61517c76..000000000 --- a/Ocaml+printf/lib/parser.ml +++ /dev/null @@ -1,434 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Ast - -let is_whitespace = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_low_letter = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_up_letter = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_letter c = is_low_letter c || is_up_letter c - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_keyword = function - | "else" - | "false" - | "fun" - | "if" - | "in" - | "let" - | "match" - | "or" - | "rec" - | "then" - | "true" - | "with" -> true - | _ -> false -;; - -let take_whitespaces = take_while is_whitespace -let take_whitespaces1 = take_while1 is_whitespace -let token1 = take_while1 (fun c -> is_letter c || is_digit c || c = '_') - -let keyword s = - take_whitespaces *> token1 - >>= fun res -> if res = s then return s else fail "keyword expected" -;; - -let whitespace1_keyword s = - take_whitespaces1 *> token1 - >>= fun res -> if res = s then return s else fail "keyword expected" -;; - -let valname = - token1 - >>= (fun s -> - let c = s.[0] in - if (not (is_keyword s)) && s <> "_" && (is_low_letter c || c = '_') - then return s - else fail "name of value expected") - >>| fun s -> LCIdent s -;; - -let expr_valname = take_whitespaces *> valname >>| fun x -> Expr_val x - -let const_integer = - token1 - >>= fun s -> - let cons x = Int x in - try int_of_string s |> cons |> return with - | Failure _ -> fail "integer expected" -;; - -let expr_integer = take_whitespaces *> const_integer >>| fun x -> Expr_const x - -let const_bool = - token1 - >>= function - | "false" -> return @@ Bool false - | "true" -> return @@ Bool true - | _ -> fail "Bool constant expected" -;; - -let expr_bool = take_whitespaces *> const_bool >>| fun x -> Expr_const x - -let const_char = - char '\'' - *> (peek_char_fail - >>= fun c -> - match c with - | '\\' -> - peek_string 2 - >>= fun s -> - (match s with - | {|\n|} -> advance 2 *> return '\n' - | {|\t|} -> advance 2 *> return '\t' - | {|\b|} -> advance 2 *> return '\b' - | {|\r|} -> advance 2 *> return '\r' - | {|\\|} -> advance 2 *> return '\\' - | {|\'|} -> advance 2 *> return '\'' - | {|\"|} -> advance 2 *> return '\"' - | {|\ |} -> advance 2 *> return '\ ' - | ({|\x|} | {|\o|} | _) when is_digit s.[1] -> - fail "Escape sequense is not supported" - | _ -> fail "Illegal backslash escape in character") - | _ -> advance 1 *> return c) - <* char '\'' - >>| fun c -> Char c -;; - -let expr_char = take_whitespaces *> const_char >>| fun c -> Expr_const c - -let const_string = - let rec helper acc = - peek_char_fail - >>= function - | '"' -> advance 1 *> return acc - | '\\' -> - take 2 - >>= (function - | {|\n|} -> helper (acc ^ "\n") - | {|\t|} -> helper (acc ^ "\t") - | {|\b|} -> helper (acc ^ "\b") - | {|\r|} -> helper (acc ^ "\r") - | {|\\|} -> helper (acc ^ "\\") - | {|\'|} -> helper (acc ^ "\'") - | {|\"|} -> helper (acc ^ "\"") - | {|\ |} -> helper (acc ^ " ") - | _ -> fail "Illegal (or not supported) backslash escape in string") - | _ -> take 1 >>= fun t -> helper (acc ^ t) - in - char '\"' *> helper "" >>| fun s -> String s -;; - -let expr_string = take_whitespaces *> const_string >>| fun c -> Expr_const c - -(* fails if s with characters after that can be interpreted by OCaml as user-defined operator *) -let op_parse_helper s = - let second_operator_char = function - | '$' - | '&' - | '*' - | '+' - | '-' - | '/' - | '=' - | '>' - | '@' - | '^' - | '|' - | '%' - | '<' - | '!' - | '.' - | ':' - | '?' - | '~' -> true - | _ -> false - in - string s *> peek_char - >>= function - | Some x when second_operator_char x -> fail "unsopported operator" - | _ -> return "" -;; - -let left_bracket = take_whitespaces *> char '(' -let right_bracket = take_whitespaces *> char ')' -let parenthesis p = left_bracket *> take_whitespaces *> p <* right_bracket - -let mul = - take_whitespaces *> op_parse_helper "*" *> return (fun e1 e2 -> Bin_op (Mul, e1, e2)) -;; - -let div = - take_whitespaces *> op_parse_helper "/" *> return (fun e1 e2 -> Bin_op (Div, e1, e2)) -;; - -let add = - take_whitespaces *> op_parse_helper "+" *> return (fun e1 e2 -> Bin_op (Add, e1, e2)) -;; - -let sub = - take_whitespaces *> op_parse_helper "-" *> return (fun e1 e2 -> Bin_op (Sub, e1, e2)) -;; - -let rel = - let eq = - take_whitespaces *> op_parse_helper "=" *> return (fun e1 e2 -> Bin_op (Eq, e1, e2)) - in - let neq = - take_whitespaces *> op_parse_helper "<>" *> return (fun e1 e2 -> Bin_op (Neq, e1, e2)) - in - let less = - take_whitespaces *> op_parse_helper "<" *> return (fun e1 e2 -> Bin_op (Less, e1, e2)) - in - let leq = - take_whitespaces *> op_parse_helper "<=" *> return (fun e1 e2 -> Bin_op (Leq, e1, e2)) - in - let gre = - take_whitespaces *> op_parse_helper ">" *> return (fun e1 e2 -> Bin_op (Gre, e1, e2)) - in - let geq = - take_whitespaces *> op_parse_helper ">=" *> return (fun e1 e2 -> Bin_op (Geq, e1, e2)) - in - choice [ eq; neq; less; leq; gre; geq ] -;; - -let and_op = - take_whitespaces *> op_parse_helper "&&" *> return (fun e1 e2 -> Bin_op (And, e1, e2)) -;; - -let or_op = - take_whitespaces *> op_parse_helper "||" *> return (fun e1 e2 -> Bin_op (Or, e1, e2)) -;; - -let concat_op = - take_whitespaces *> op_parse_helper "^" *> return (fun e1 e2 -> Bin_op (Concat, e1, e2)) -;; - -let concat_format_op = - take_whitespaces - *> op_parse_helper "^^" - *> return (fun e1 e2 -> Bin_op (Concat_format, e1, e2)) -;; - -let list_cons_op = - take_whitespaces - *> op_parse_helper "::" - *> return (fun e1 e2 -> Expr_cons_list (e1, e2)) -;; - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let rec chainr1 e op = e >>= fun a -> op >>= (fun f -> chainr1 e op >>| f a) <|> return a - -let unary_op expr_item_parser = - fix (fun cur_expr -> - take_whitespaces - *> choice - [ (op_parse_helper "+" *> cur_expr >>| fun e -> Un_op (Un_plus, e)) - ; (op_parse_helper "-" *> cur_expr >>| fun e -> Un_op (Un_minus, e)) - ; expr_item_parser - ]) -;; - -let if_then_else expr_item_parser = - lift3 - (fun e1 e2 e3 -> Expr_ite (e1, e2, e3)) - (keyword "if" *> expr_item_parser) - (keyword "then" *> expr_item_parser) - (keyword "else" *> expr_item_parser) -;; - -let parse_tuple expr = - expr - >>= (fun first_expr -> - many1 (take_whitespaces *> char ',' *> expr) - >>| fun expr_list -> Expr_tuple (first_expr, expr_list)) - <|> expr -;; - -let parse_list expr = - let parse_empty = - take_whitespaces *> char '[' *> take_whitespaces *> char ']' - >>| fun _ -> Expr_empty_list - in - parse_empty - <|> take_whitespaces - *> char '[' - *> fix (fun cur_parser -> - choice - [ (expr - <* take_whitespaces - <* char ']' - >>| fun e -> Expr_cons_list (e, Expr_empty_list)) - ; (expr - <* take_whitespaces - <* char ';' - >>= fun e -> cur_parser >>| fun l -> Expr_cons_list (e, l)) - ]) -;; - -let parse_any_pat = - take_whitespaces *> token1 - >>= fun s -> if s = "_" then return Pat_any else fail {|Pattern "any" expected|} -;; - -let parse_val_pat = take_whitespaces *> valname >>| fun s -> Pat_val s - -let parse_const_pat = - let parse_const = choice [ const_integer; const_bool; const_char; const_string ] in - take_whitespaces *> parse_const >>| fun c -> Pat_const c -;; - -let parse_pat_empty_list = - take_whitespaces *> char '[' *> take_whitespaces *> char ']' >>| fun _ -> Pat_empty_list -;; - -let parse_pat = - take_whitespaces - *> fix (fun cur_pat -> - let parse_base_pat = - choice [ parse_any_pat; parse_val_pat; parse_const_pat; parse_pat_empty_list ] - in - let parse_cons_pat = - let helper = - take_whitespaces - *> op_parse_helper "::" - *> return (fun p1 p2 -> Pat_cons_list (p1, p2)) - in - chainr1 (parenthesis cur_pat <|> parse_base_pat) helper - in - let parse_tuple_pat = - parenthesis cur_pat - <|> parse_base_pat - >>= fun first_pat -> - many1 (take_whitespaces *> char ',' *> (parenthesis cur_pat <|> parse_base_pat)) - >>| fun pat_list -> Pat_tuple (first_pat, pat_list) - in - choice [ parse_tuple_pat; parse_cons_pat; parse_base_pat; parenthesis cur_pat ]) -;; - -let expr_match expr = - let case = - take_whitespaces *> char '|' *> parse_pat - >>= fun pat -> take_whitespaces *> op_parse_helper "->" *> expr >>| fun e -> pat, e - in - keyword "match" *> expr - >>= fun e -> keyword "with" *> many1 case >>| fun l -> Expr_match (e, l) -;; - -(* for parsing arguments and body of function *) -let fun_helper expr sep = - let rec helper e = function - | [] -> e - | h :: tl -> Expr_fun (h, helper e tl) - in - many1 parse_pat - >>= fun args -> - take_whitespaces *> op_parse_helper sep *> expr >>| fun e -> helper e args -;; - -let expr_fun expr = keyword "fun" *> take_whitespaces1 *> fun_helper expr "->" - -let let_in expr = - keyword "let" - *> lift4 - (fun rec_flag name expr1 expr2 -> Expr_let ((rec_flag, name, expr1), expr2)) - (option false (whitespace1_keyword "rec" >>| fun _ -> true)) - (take_whitespaces1 *> valname) - (take_whitespaces *> op_parse_helper "=" *> expr - <|> take_whitespaces1 *> fun_helper expr "=" - <* keyword "in") - expr -;; - -let get_by_id expr = - expr - >>= (fun str -> - take_whitespaces *> char '.' *> take_whitespaces *> char '[' *> expr - >>= fun id -> - take_whitespaces *> char ']' - >>| fun _ -> Expr_app (Expr_app (Expr_val (LCIdent "get"), str), id)) - <|> expr -;; - -let seq_op = take_whitespaces *> char ';' *> return (fun e1 e2 -> Expr_seq (e1, e2)) - -let expr = - take_whitespaces - *> fix (fun all_expr -> - let cur_expr = - choice - [ expr_integer - ; expr_bool - ; expr_char - ; expr_string - ; expr_valname - ; parenthesis all_expr - ] - in - let cur_expr = parse_list cur_expr <|> cur_expr in - let cur_expr = get_by_id cur_expr in - let cur_expr = chainl1 cur_expr (return (fun e1 e2 -> Expr_app (e1, e2))) in - let cur_expr = unary_op cur_expr in - let cur_expr = chainl1 cur_expr (mul <|> div) in - let cur_expr = chainl1 cur_expr (add <|> sub) in - let cur_expr = chainr1 cur_expr list_cons_op in - let cur_expr = chainl1 cur_expr (concat_op <|> concat_format_op) in - let cur_expr = chainl1 cur_expr rel in - let cur_expr = chainr1 cur_expr and_op in - let cur_expr = chainr1 cur_expr or_op in - let cur_expr = parse_tuple cur_expr in - choice - [ if_then_else all_expr - ; chainr1 cur_expr seq_op - ; let_in all_expr - ; expr_match all_expr - ; expr_fun all_expr - ; cur_expr - ]) - <* take_whitespaces -;; - -let decl = - keyword "let" - *> lift3 - (fun rec_flag name expr -> Let_decl (rec_flag, name, expr)) - (option false (whitespace1_keyword "rec" >>| fun _ -> true)) - (take_whitespaces1 *> valname) - (take_whitespaces *> op_parse_helper "=" *> expr - <|> take_whitespaces1 *> fun_helper expr "=") - <* take_whitespaces - <* option "" (string ";;") -;; - -let expr_top = expr >>| fun e -> Expr e - -let program_parser : program t = - let empty_decl = many (take_whitespaces *> string ";;") in - many1 (empty_decl *> (decl <|> expr_top) <* empty_decl) <* take_whitespaces -;; - -let run_parser_program s = parse_string ~consume:All program_parser s -let run_parser_expr s = parse_string ~consume:All expr s diff --git a/Ocaml+printf/lib/parser.mli b/Ocaml+printf/lib/parser.mli deleted file mode 100644 index 2e50d6aea..000000000 --- a/Ocaml+printf/lib/parser.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** creates AST from text of program *) -val run_parser_program : string -> (Ast.program, string) result - -(** creates AST from expression represented by a string *) -val run_parser_expr : string -> (Ast.expr, string) result diff --git a/Ocaml+printf/lib/pprint.ml b/Ocaml+printf/lib/pprint.ml deleted file mode 100644 index 04441682c..000000000 --- a/Ocaml+printf/lib/pprint.ml +++ /dev/null @@ -1,85 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* match typed variables to letters *) -let assign_names typ = - let calc_name letter num = - "\'" - ^ - if num = 0 - then Base.Char.to_string letter - else Base.Char.to_string letter ^ Int.to_string num - in - let next_letter c = Base.Char.of_int_exn (Base.Char.to_int c + 1) in - let next letter num = - if Char.equal letter 'z' then 'a', num + 1 else next_letter letter, num - in - let rec helper names letter num = function - | Typedtree.TVar n -> - (match Base.Map.add names ~key:n ~data:(calc_name letter num) with - | `Ok new_names -> new_names, next letter num - | `Duplicate -> names, (letter, num)) - | TArr (l, r) -> - let names, (letter, num) = helper names letter num l in - helper names letter num r - | TList t -> helper names letter num t - | TTuple (h, list) -> - List.fold_left - (fun (names, (letter, num)) -> helper names letter num) - (names, (letter, num)) - (h :: list) - | _ -> names, (letter, num) - in - let names, (_, _) = helper (Base.Map.empty (module Base.Int)) 'a' 0 typ in - names -;; - -(* pretty print types with letters *) -let pp_typ ppf typ = - let open Typedtree in - let names = assign_names typ in - let rec helper ppf = function - | TVar n -> - (try Format.fprintf ppf "%s" (Base.Map.find_exn names n) with - | Base.Not_found_s _ | Stdlib.Not_found -> - Format.fprintf ppf "Names for types are counted incorrectly") - | TPrim s -> Format.fprintf ppf "%s" s - | TArr (l, r) -> - (match l, r with - | TArr (_, _), _ -> Format.fprintf ppf "(%a) -> %a" helper l helper r - | _ -> Format.fprintf ppf "%a -> %a" helper l helper r) - | TUnit -> Format.fprintf ppf "unit" - | TTuple (h, list) -> - let print_item item fmt = - match item with - | TArr (_, _) | TTuple _ -> Format.fprintf ppf (fmt ^^ "(%a)") helper item - | _ -> Format.fprintf ppf (fmt ^^ "%a") helper item - in - List.fold_left (fun _ item -> print_item item " * ") (print_item h "") list - | TList t -> Format.fprintf ppf "%a list" helper t - | TFString t -> Format.fprintf ppf "%a format_string" helper t - in - helper ppf typ -;; - -(* print scheme without binded vars *) -let pp_scheme_binder ppf (Typedtree.Scheme (binder_set, typ)) = - let open Typedtree in - let names = assign_names typ in - try - if not (TypeVarSet.is_empty binder_set) then Format.fprintf ppf "forall"; - TypeVarSet.iter - (fun n -> Format.fprintf ppf " %s" (Base.Map.find_exn names n)) - binder_set; - if not (TypeVarSet.is_empty binder_set) then Format.fprintf ppf ". "; - Format.fprintf ppf "%a" pp_typ typ - with - | Base.Not_found_s _ | Stdlib.Not_found -> - Format.fprintf ppf "Binder set does not match the type" -;; - -(* print scheme without binded vars *) -let pp_scheme_without ppf = function - | Typedtree.Scheme (_, t) -> Format.fprintf ppf "%a" pp_typ t -;; diff --git a/Ocaml+printf/lib/pprint.mli b/Ocaml+printf/lib/pprint.mli deleted file mode 100644 index ca8871890..000000000 --- a/Ocaml+printf/lib/pprint.mli +++ /dev/null @@ -1,7 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp_typ : Format.formatter -> Typedtree.typ -> unit -val pp_scheme_binder : Format.formatter -> Typedtree.scheme -> unit -val pp_scheme_without : Format.formatter -> Typedtree.scheme -> unit diff --git a/Ocaml+printf/lib/tests/infer_tests.ml b/Ocaml+printf/lib/tests/infer_tests.ml deleted file mode 100644 index 3b936bf28..000000000 --- a/Ocaml+printf/lib/tests/infer_tests.ml +++ /dev/null @@ -1,316 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -let infer_expr_and_print_typ str = - let parsed = Result.get_ok (Parser.run_parser_expr str) in - match Inferencer.run_infer_expr parsed with - | Ok (ty, _) -> Format.printf "%a" Pprint.pp_typ ty - | Error err -> Format.printf "%a" Inferencer.pp_error err -;; - -let infer_program_and_print_env str = - let parsed = Result.get_ok (Parser.run_parser_program str) in - match Inferencer.run_infer_program parsed with - | Ok (env, _) -> Format.printf "%a" Inferencer.TypeEnv.pp_env env - | Error err -> Format.printf "%a" Inferencer.pp_error err -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f x g = g x in f|} in - [%expect {| 'a -> ('a -> 'b) -> 'b |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ - {|let f x g = g x in let id x = x in let fst x y = x in fst (f id)|} - in - [%expect {| 'a -> (('b -> 'b) -> 'c) -> 'c |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| fun f -> fun x -> f x |} in - [%expect {| ('a -> 'b) -> 'a -> 'b |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ {|let id x = x in if (id 2 < 3) then id else (fun t -> t)|} - in - [%expect {| 'a -> 'a |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let t _ a = a in 1|} in - [%expect {| int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|fun (a,b,c,d) -> a + d|} in - [%expect {| int * 'a * 'b * int -> int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|fun (a,b,(2::t),d) -> a + d|} in - [%expect {| int * 'a * int list * int -> int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f ((1,2)::y) = 0 in f |} in - [%expect {| int * int list -> int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f (1,_,y) = y in f |} in - [%expect {| int * 'a * 'b -> 'b |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let a = [] in a |} in - [%expect {| 'a list |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f a = a::['c';'d'] in f |} in - [%expect {| char -> char list |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ {|let rec f n = if n <= 1 then 0 else n * f (n - 1) in f|} - in - [%expect {| int -> int |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ - {|let rec f (a, b) = if a + b < 10 then a + b else f (a-1,b-1) in f|} - in - [%expect {| int * int -> int |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ {|let f x = match x with | [] -> "end" | h::tl -> h in f |} - in - [%expect {| string list -> string |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let x = 1 in match x with | a -> 3 |} in - [%expect {| int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| "as%dad" ^^ "sfs%c" |} in - [%expect {| - int -> char -> unit format_string |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let str = format_of_string "%d%d%ddfs" in str|} in - [%expect {| - int -> int -> int -> unit format_string |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ {| let str = format_of_string "%c" in (str ^^ "%d%s")|} - in - [%expect {| - char -> int -> string -> unit format_string |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let fmt = format_of_string in fmt "%c" |} in - [%expect {| - char -> unit format_string |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ - {| let c = 'c' in let my_printf = printf "%c" in my_printf c |} - in - [%expect {| - unit |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ - {| let fs = format_of_string "%d%Babc" in printf (fs ^^ "%s") |} - in - [%expect {| - int -> bool -> string -> unit |}] -;; - -let%expect_test _ = - let _ = - infer_program_and_print_env - {| - let rec fac n = if n <= 1 then 1 else n * fac (n - 1) - let a = fac 6 - let rev list = - let rec helper acc list = - match list with - | [] -> acc - | h :: tl -> helper (h :: acc) tl - in - helper [] list - let reversed1 = rev [1;2;3;4;5] - let reversed2 = rev [true;false;false;false] - |} - in - [%expect - {| - val a : int - val fac : int -> int - val rev : forall 'a. 'a list -> 'a list - val reversed1 : int list - val reversed2 : bool list |}] -;; - -let%expect_test _ = - let _ = - infer_program_and_print_env - {|let fmt = "%d%B" ^^ "%c%s";; - printf fmt 1 true 'a' "abc"|} - in - [%expect {| - val fmt : int -> bool -> char -> string -> unit format_string |}] -;; - -(* Errors *) - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let s = "123" in (s ^^ "%d") |} in - [%expect {| Invalid format concatination of "string" and "int -> unit format_string" |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| printf "%" |} in - [%expect {| Invalid format string "%" |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| fun (a,a) -> a + a |} in - [%expect {| Variable a is bound several times in matching |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let rec f x = f in f |} in - [%expect {| Occurs check failed |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f (a,b) = a + b in f (1,2,3)|} in - [%expect {| Unification failed on int * int and int * int * int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let rec f x = f in f |} in - [%expect {| Occurs check failed |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| let f x = x + 1; x || true; "asdad" in x |} in - [%expect {| Unification failed on int and unit |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ {| let x = 1 in match x with | 0 -> 'c' | _ -> "abc" |} - in - [%expect {| Unification failed on char and string |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f (a::1) = 0 in f |} in - [%expect {| Unification failed on int and 'a list |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f x = a in f|} in - [%expect {| Undefined variable "a" |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f x = "sdfsdf" || true in f |} in - [%expect {| Unification failed on string and bool |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let b = 'c' in let a = 1::b::2::[] in a|} in - [%expect {| Unification failed on char and int |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|let f x = f 1 in f |} in - [%expect {| Undefined variable "f" |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {|fun f x -> x x|} in - [%expect {| Occurs check failed |}] -;; - -let%expect_test _ = - let _ = infer_expr_and_print_typ {| - let rec fix f x = f (fix f) x in - fix - |} in - [%expect {| (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b |}] -;; - -let%expect_test "Formatted Logging" = - let _ = - infer_expr_and_print_typ - {| - let log ppf = - if true then printf ppf - else printf ppf - in - log "%s" "asdf" - |} - in - [%expect {| unit |}] -;; - -let%expect_test "Weird but OK" = - let _ = infer_expr_and_print_typ {| (fun x -> format_of_string x) "asd%df" |} in - [%expect {| - int -> unit format_string |}] -;; - -(* expression (fun x -> format_of_string x) "asd%df" is not a function - In OCaml it is also an error *) -let%expect_test "Why error?" = - let _ = infer_expr_and_print_typ {| (fun x -> format_of_string x) "asd%df" 11 |} in - [%expect {| - Unification failed on int -> unit format_string and int -> 'a |}] -;; - -(* Perhaps you meant *) -let%expect_test "printf" = - let _ = - infer_expr_and_print_typ {| printf ((fun x -> format_of_string x) "asd%df") 11 |} - in - [%expect {| - unit |}] -;; - -let%expect_test _ = - let _ = - infer_expr_and_print_typ - {|let f a b = - let inc = (fun a -> a + 1) in - (fun b -> b) inc (a b) - in f|} - in - [%expect {| ('a -> int) -> 'a -> int |}] -;; diff --git a/Ocaml+printf/lib/tests/infer_tests.mli b/Ocaml+printf/lib/tests/infer_tests.mli deleted file mode 100644 index 7fcbba92e..000000000 --- a/Ocaml+printf/lib/tests/infer_tests.mli +++ /dev/null @@ -1,3 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) diff --git a/Ocaml+printf/lib/tests/interpret_tests.ml b/Ocaml+printf/lib/tests/interpret_tests.ml deleted file mode 100644 index 644747aa9..000000000 --- a/Ocaml+printf/lib/tests/interpret_tests.ml +++ /dev/null @@ -1,183 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -(* for tests assumed that parsing and type inference was succsessful *) -let eval_expr_and_print str = - let res = Result.get_ok (Parser.run_parser_expr str) in - let _, res = Result.get_ok (Inferencer.run_infer_expr res) in - let res = Interpreter.run_eval_expr res in - match res with - | Base.Result.Ok v -> Format.printf "%a" Interpreter.pp_value v - | Base.Result.Error err -> Format.printf "%a" Interpreter.pp_error err -;; - -let eval_program_and_print str = - let res = Result.get_ok (Parser.run_parser_program str) in - let _, res = Result.get_ok (Inferencer.run_infer_program res) in - let res = Interpreter.run_eval_program res in - match res with - | Base.Result.Ok v -> Format.printf "%a" Interpreter.EnvValues.pp_env_values v - | Base.Result.Error err -> Format.printf "%a" Interpreter.pp_error err -;; - -let%expect_test _ = - let _ = - eval_program_and_print {| - let i = 0 - let str = "abc" - let c = str.[i] - |} - in - [%expect {| - val c = 'a' - val i = 0 - val str = "abc" |}] -;; - -let%expect_test _ = - let _ = - eval_program_and_print - {| - let str = "1234567" - let c = get str 1 - let b = false;; - printf "string: %s; bool: %B\nnum: %d; char: %c\n" "abcdef" b 123 c - let fmt1 = format_of_string "char2: %c; string: %s\n" - let fmt2 = "char1: %c; " ^^ fmt1 - let fmt3 = format_of_string fmt2 - let my_printf = printf fmt3;; - my_printf str.[(length str - 1)] c "str" - |} - in - [%expect - {| - string: abcdef; bool: false - num: 123; char: 2 - char1: 7; char2: 2; string: str - val b = false - val c = '2' - val fmt1 = "char2: %c; string: %s\n" format - val fmt2 = "char1: %c; char2: %c; string: %s\n" format - val fmt3 = "char1: %c; char2: %c; string: %s\n" format - val my_printf = - val str = "1234567" |}] -;; - -let%expect_test _ = - let _ = - eval_program_and_print - {| - let rec fac n = if n <= 1 then 1 else n * fac (n - 1) - let a = fac 6 - let rev list = - let rec helper acc list = - match list with - | [] -> acc - | h :: tl -> helper (h :: acc) tl - in - helper [] list - let reversed1 = rev [1;2;3;4;5] - let reversed2 = rev [true;false;false;false] - |} - in - [%expect - {| - val a = 720 - val fac = - val rev = - val reversed1 = [5; 4; 3; 2; 1] - val reversed2 = [false; false; false; true] |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let f = 2 in f|} in - [%expect {| 2 |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let a = 1 in let b = 2 in let c = 3 in a + b * c|} in - [%expect {| 7 |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let id x = x in let b a = id a in b 5|} in - [%expect {| 5 |}] -;; - -let%expect_test _ = - let _ = - eval_expr_and_print {|let rec f n = if n <= 1 then 1 else n * f (n - 1) in f 5|} - in - [%expect {| 120 |}] -;; - -let%expect_test _ = - let _ = - eval_expr_and_print - {|let rec f a b = if a + b > 100 then a + b else f (a + 3) (b * 2) in f 1 5 |} - in - [%expect {| 176 |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let rec x = 1 in x|} in - [%expect {| 1 |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let str = "abc" in str.[0]|} in - [%expect {| 'a' |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let a = (1+3*4, 'c', "ab" ^ "cd", true) in a|} in - [%expect {| (13, 'c', "abcd", true) |}] -;; - -let%expect_test _ = - let _ = - eval_expr_and_print - {|let a = 1::2::[3;4] in match a with | h::tl -> (h, tl) | _ -> (1,[2])|} - in - [%expect {| (1, [2; 3; 4]) |}] -;; - -let%expect_test _ = - let _ = - eval_expr_and_print - {|let str = "abc" in let a = (str, 'c') in match a with | ("abc", _) -> "yes" | _ -> "no"|} - in - [%expect {| "yes" |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let fst (a, b) = a in fst (2,3)|} in - [%expect {| 2 |}] -;; - -(* errors *) - -let%expect_test _ = - let _ = eval_expr_and_print {|let str = "a\nc" in str.[3]|} in - [%expect {| Invalid argument: Index out of bounds |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let a = 0 in let b = 1 in b / a|} in - [%expect {| Division by zero |}] -;; - -let%expect_test _ = - let _ = eval_expr_and_print {|let f x = match x with | h::tl -> 1 in f []|} in - [%expect {| Matching failure |}] -;; - -(* I have two functions: "eval_program_and_print" and "eval_expr_and_print" - In this test you wrote a declaration, so I replaced function *) -let%expect_test _ = - let _ = eval_program_and_print {|let f x = format_of_string x|} in - [%expect {| val f = |}] -;; diff --git a/Ocaml+printf/lib/tests/interpret_tests.mli b/Ocaml+printf/lib/tests/interpret_tests.mli deleted file mode 100644 index 7fcbba92e..000000000 --- a/Ocaml+printf/lib/tests/interpret_tests.mli +++ /dev/null @@ -1,3 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) diff --git a/Ocaml+printf/lib/tests/parser_tests.ml b/Ocaml+printf/lib/tests/parser_tests.ml deleted file mode 100644 index 28af0c405..000000000 --- a/Ocaml+printf/lib/tests/parser_tests.ml +++ /dev/null @@ -1,317 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ocaml_printf_lib - -let parse_and_print str = - match Parser.run_parser_program str with - | Result.Ok program -> Format.printf "%a\n" Ast.pp_program program - | Result.Error str -> Format.printf "Parsing error%s\n" str -;; - -let%expect_test _ = - parse_and_print {| ;; ;;;; ;; ;;let _a=1;; ;;;; let _b =1+2 |}; - [%expect - {| - [(Let_decl (false, (LCIdent "_a"), (Expr_const (Int 1)))); - (Let_decl - (false, (LCIdent "_b"), - (Bin_op (Add, (Expr_const (Int 1)), (Expr_const (Int 2)))))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let a = 10/( 2+(+ +5) )*( 7 + - 1) - ( 1 + 2* 3 ) |}; - [%expect - {| - [(Let_decl - (false, (LCIdent "a"), - (Bin_op (Sub, - (Bin_op (Mul, - (Bin_op (Div, (Expr_const (Int 10)), - (Bin_op (Add, (Expr_const (Int 2)), - (Un_op (Un_plus, (Un_op (Un_plus, (Expr_const (Int 5)))))))) - )), - (Bin_op (Add, (Expr_const (Int 7)), - (Un_op (Un_minus, (Expr_const (Int 1)))))) - )), - (Bin_op (Add, (Expr_const (Int 1)), - (Bin_op (Mul, (Expr_const (Int 2)), (Expr_const (Int 3)))))) - )))) - ] |}] -;; - -(* factorial *) -let%expect_test _ = - parse_and_print {|let rec fac n = if n <= 1 then 1 else n * fac (n - 1)|}; - [%expect - {| - [(Let_decl - (true, (LCIdent "fac"), - (Expr_fun ((Pat_val (LCIdent "n")), - (Expr_ite ( - (Bin_op (Leq, (Expr_val (LCIdent "n")), (Expr_const (Int 1)))), - (Expr_const (Int 1)), - (Bin_op (Mul, (Expr_val (LCIdent "n")), - (Expr_app ((Expr_val (LCIdent "fac")), - (Bin_op (Sub, (Expr_val (LCIdent "n")), (Expr_const (Int 1)) - )) - )) - )) - )) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let f = fun a b -> fun z -> a + b * z|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "f"), - (Expr_fun ((Pat_val (LCIdent "a")), - (Expr_fun ((Pat_val (LCIdent "b")), - (Expr_fun ((Pat_val (LCIdent "z")), - (Bin_op (Add, (Expr_val (LCIdent "a")), - (Bin_op (Mul, (Expr_val (LCIdent "b")), - (Expr_val (LCIdent "z")))) - )) - )) - )) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print - {|let f = if true then if true then a else b else if false then x else y|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "f"), - (Expr_ite ((Expr_const (Bool true)), - (Expr_ite ((Expr_const (Bool true)), (Expr_val (LCIdent "a")), - (Expr_val (LCIdent "b")))), - (Expr_ite ((Expr_const (Bool false)), (Expr_val (LCIdent "x")), - (Expr_val (LCIdent "y")))) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print - {|let a = let id x = x in let f = fun x -> if x > 0 then t else id b in f 1|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "a"), - (Expr_let ( - (false, (LCIdent "id"), - (Expr_fun ((Pat_val (LCIdent "x")), (Expr_val (LCIdent "x"))))), - (Expr_let ( - (false, (LCIdent "f"), - (Expr_fun ((Pat_val (LCIdent "x")), - (Expr_ite ( - (Bin_op (Gre, (Expr_val (LCIdent "x")), - (Expr_const (Int 0)))), - (Expr_val (LCIdent "t")), - (Expr_app ((Expr_val (LCIdent "id")), - (Expr_val (LCIdent "b")))) - )) - ))), - (Expr_app ((Expr_val (LCIdent "f")), (Expr_const (Int 1)))))) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let tuple1 = (1,x, 1+2 , (1, 2, 3))|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "tuple1"), - (Expr_tuple ((Expr_const (Int 1)), - [(Expr_val (LCIdent "x")); - (Bin_op (Add, (Expr_const (Int 1)), (Expr_const (Int 2)))); - (Expr_tuple ((Expr_const (Int 1)), - [(Expr_const (Int 2)); (Expr_const (Int 3))])) - ] - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let a =5::4::[1; 2; 3]|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "a"), - (Expr_cons_list ((Expr_const (Int 5)), - (Expr_cons_list ((Expr_const (Int 4)), - (Expr_cons_list ((Expr_const (Int 1)), - (Expr_cons_list ((Expr_const (Int 2)), - (Expr_cons_list ((Expr_const (Int 3)), Expr_empty_list)))) - )) - )) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print - {|let f x = match x with - | h::tl -> let x = 1 in x - | _ -> let id = fun x -> x in - if (0 < 1) then 2 else id 3|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "f"), - (Expr_fun ((Pat_val (LCIdent "x")), - (Expr_match ((Expr_val (LCIdent "x")), - [((Pat_cons_list ((Pat_val (LCIdent "h")), - (Pat_val (LCIdent "tl")))), - (Expr_let ((false, (LCIdent "x"), (Expr_const (Int 1))), - (Expr_val (LCIdent "x"))))); - (Pat_any, - (Expr_let ( - (false, (LCIdent "id"), - (Expr_fun ((Pat_val (LCIdent "x")), - (Expr_val (LCIdent "x"))))), - (Expr_ite ( - (Bin_op (Less, (Expr_const (Int 0)), (Expr_const (Int 1)) - )), - (Expr_const (Int 2)), - (Expr_app ((Expr_val (LCIdent "id")), - (Expr_const (Int 3)))) - )) - ))) - ] - )) - )))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let k = let f ((t::1::(1,2)::y), 3) = a in f|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "k"), - (Expr_let ( - (false, (LCIdent "f"), - (Expr_fun ( - (Pat_tuple ( - (Pat_cons_list ((Pat_val (LCIdent "t")), - (Pat_cons_list ((Pat_const (Int 1)), - (Pat_cons_list ( - (Pat_tuple ((Pat_const (Int 1)), - [(Pat_const (Int 2))])), - (Pat_val (LCIdent "y")))) - )) - )), - [(Pat_const (Int 3))])), - (Expr_val (LCIdent "a"))))), - (Expr_val (LCIdent "f")))))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|let f = printf "sdfsdf"; prtinf "sfsf%c %d";; [323;32]|}; - [%expect - {| - [(Let_decl - (false, (LCIdent "f"), - (Expr_seq ( - (Expr_app ((Expr_val (LCIdent "printf")), - (Expr_const (String "sdfsdf")))), - (Expr_app ((Expr_val (LCIdent "prtinf")), - (Expr_const (String "sfsf%c %d")))) - )))); - (Expr - (Expr_cons_list ((Expr_const (Int 323)), - (Expr_cons_list ((Expr_const (Int 32)), Expr_empty_list))))) - ] |}] -;; - -let%expect_test _ = - parse_and_print {|1; 2 let x = 1;; let a = 2; 3|}; - [%expect - {| - [(Expr (Expr_seq ((Expr_const (Int 1)), (Expr_const (Int 2))))); - (Let_decl (false, (LCIdent "x"), (Expr_const (Int 1)))); - (Let_decl - (false, (LCIdent "a"), - (Expr_seq ((Expr_const (Int 2)), (Expr_const (Int 3)))))) - ] |}] -;; - -let%expect_test _ = - let _ = parse_and_print {| let str = "sdfs"; printf "%c" str.[0]; [] |} in - [%expect - {| - [(Let_decl - (false, (LCIdent "str"), - (Expr_seq ((Expr_const (String "sdfs")), - (Expr_seq ( - (Expr_app ( - (Expr_app ((Expr_val (LCIdent "printf")), - (Expr_const (String "%c")))), - (Expr_app ( - (Expr_app ((Expr_val (LCIdent "get")), - (Expr_val (LCIdent "str")))), - (Expr_const (Int 0)))) - )), - Expr_empty_list)) - )))) - ] |}] -;; - -let%expect_test _ = - let _ = parse_and_print {| printf "%s" str |} in - [%expect - {| - [(Expr - (Expr_app ( - (Expr_app ((Expr_val (LCIdent "printf")), (Expr_const (String "%s")))), - (Expr_val (LCIdent "str"))))) - ] |}] -;; - -let%expect_test _ = - let _ = parse_and_print {|let str = "\n\\\"\t\n"|} in - [%expect - {| - [(Let_decl (false, (LCIdent "str"), (Expr_const (String "\n\\\"\t\n"))))] |}] -;; - -(* errors*) - -let%expect_test _ = - let _ = parse_and_print {| let a = 2 +- 3;; let b =+2 |} in - [%expect {| - Parsing error: end_of_input |}] -;; - -let%expect_test _ = - let _ = parse_and_print {|let str = "\x"|} in - [%expect {| - Parsing error: no more choices |}] -;; - -let%expect_test _ = - let _ = parse_and_print {|let f (a, b) = a + b;; let a = f (1, 2)|} in - [%expect - {| - [(Let_decl - (false, (LCIdent "f"), - (Expr_fun ( - (Pat_tuple ((Pat_val (LCIdent "a")), [(Pat_val (LCIdent "b"))])), - (Bin_op (Add, (Expr_val (LCIdent "a")), (Expr_val (LCIdent "b")))))))); - (Let_decl - (false, (LCIdent "a"), - (Expr_app ((Expr_val (LCIdent "f")), - (Expr_tuple ((Expr_const (Int 1)), [(Expr_const (Int 2))])))))) - ] |}] -;; diff --git a/Ocaml+printf/lib/tests/parser_tests.mli b/Ocaml+printf/lib/tests/parser_tests.mli deleted file mode 100644 index 7fcbba92e..000000000 --- a/Ocaml+printf/lib/tests/parser_tests.mli +++ /dev/null @@ -1,3 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) diff --git a/Ocaml+printf/lib/typedtree.ml b/Ocaml+printf/lib/typedtree.ml deleted file mode 100644 index 393d902c1..000000000 --- a/Ocaml+printf/lib/typedtree.ml +++ /dev/null @@ -1,26 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type typ = - | TVar of int (** type var *) - | TPrim of string (** ground type *) - | TArr of typ * typ (** function type *) - | TUnit (** unit *) - | TTuple of typ * typ list (** tuple type *) - | TList of typ (** list type *) - | TFString of typ (** example: "%d%s" has type TFString (int -> char -> unit) *) - -module TypeVarSet = Stdlib.Set.Make (Int) - -type scheme = Scheme of TypeVarSet.t * typ - -let type_var x = TVar x -let int_typ = TPrim "int" -let bool_typ = TPrim "bool" -let char_typ = TPrim "char" -let string_typ = TPrim "string" -let unit_typ = TUnit -let format_typ x = TFString x -let arrow l r = TArr (l, r) -let ( @-> ) = arrow diff --git a/Ocaml+printf/lib/typedtree.mli b/Ocaml+printf/lib/typedtree.mli deleted file mode 100644 index b7ee23b93..000000000 --- a/Ocaml+printf/lib/typedtree.mli +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2023, aartdem *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type typ = - | TVar of int - | TPrim of string - | TArr of typ * typ - | TUnit - | TTuple of typ * typ list - | TList of typ - | TFString of typ - -module TypeVarSet : sig - type elt = int - type t = Set.Make(Int).t - - val empty : t - val add : elt -> t -> t - val singleton : elt -> t - val remove : elt -> t -> t - val union : t -> t -> t - val inter : t -> t -> t - val diff : t -> t -> t - val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a - val iter : (elt -> unit) -> t -> unit - val is_empty : t -> bool -end - -type scheme = Scheme of TypeVarSet.t * typ - -val type_var : int -> typ -val int_typ : typ -val bool_typ : typ -val char_typ : typ -val string_typ : typ -val unit_typ : typ -val format_typ : typ -> typ -val arrow : typ -> typ -> typ -val ( @-> ) : typ -> typ -> typ diff --git a/OcamlOOP/.gitignore b/OcamlOOP/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/OcamlOOP/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/OcamlOOP/.ocamlformat b/OcamlOOP/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/OcamlOOP/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/OcamlOOP/COPYING b/OcamlOOP/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/OcamlOOP/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/OcamlOOP/COPYING.CC0 b/OcamlOOP/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/OcamlOOP/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/OcamlOOP/COPYING.LESSER b/OcamlOOP/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/OcamlOOP/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/OcamlOOP/DONT_REMOVE_THIS_DIRECTORY.md b/OcamlOOP/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/OcamlOOP/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/OcamlOOP/Makefile b/OcamlOOP/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/OcamlOOP/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/OcamlOOP/OcamlOOP.opam b/OcamlOOP/OcamlOOP.opam deleted file mode 100644 index 54a78590f..000000000 --- a/OcamlOOP/OcamlOOP.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/OcamlOOP/README.md b/OcamlOOP/README.md deleted file mode 100644 index 57819d7ba..000000000 --- a/OcamlOOP/README.md +++ /dev/null @@ -1,92 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Artem Rzhankov, st108141@student.spbu.ru - -Features done (append only): - -- Parser - -Features in progress (and TODOs): - - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/OcamlOOP/demos/demo.ml b/OcamlOOP/demos/demo.ml deleted file mode 100644 index e522d7ce7..000000000 --- a/OcamlOOP/demos/demo.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open OcamlOOP_lib.Parser -open OcamlOOP_lib.Ast - -let test_parse = - let res = parse Stdio.In_channel.(input_all stdin) in - match res with - | Ok v -> List.iter (fun e -> print_endline (show_exp e)) v - | Error v -> prerr_endline v diff --git a/OcamlOOP/demos/demo_fact.ml b/OcamlOOP/demos/demo_fact.ml deleted file mode 100644 index aedaa067f..000000000 --- a/OcamlOOP/demos/demo_fact.ml +++ /dev/null @@ -1,13 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open OcamlOOP_lib.Parser -open OcamlOOP_lib.Ast -open Angstrom -let test_parse = - let res = parse_string ~consume: Prefix pexpr "let rec fact x = if x = 0 then 1 else x * fact (x - 1)" in - match res with - | Ok v -> print_endline (show_exp v) - | Error v -> print_endline v - diff --git a/OcamlOOP/demos/demo_obj.ml b/OcamlOOP/demos/demo_obj.ml deleted file mode 100644 index f8641af6d..000000000 --- a/OcamlOOP/demos/demo_obj.ml +++ /dev/null @@ -1,32 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open OcamlOOP_lib.Parser -open OcamlOOP_lib.Ast -open Angstrom - -(* instance from https://v2.ocaml.org/manual/objectexamples.html*) -let input = -" -let minmax x y = - if x < y - then - object - method min = x - method max = y - end - else - object - method min = y - method max = x - end -" -;; - -let test_parse = - let res = parse_string ~consume:Prefix pexpr input in - match res with - | Ok v -> print_endline (show_exp v) - | Error v -> print_endline v -;; diff --git a/OcamlOOP/demos/demo_obj1.ml b/OcamlOOP/demos/demo_obj1.ml deleted file mode 100644 index b5749dc87..000000000 --- a/OcamlOOP/demos/demo_obj1.ml +++ /dev/null @@ -1,24 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open OcamlOOP_lib.Parser -open OcamlOOP_lib.Ast -open Angstrom - -let input = -" -let p = - object (s) - val x = 5 - method private get_x = x - method print = print_int s#get_x - end -" - -let test_parse = - let res = parse_string ~consume:Prefix pexpr input in - match res with - | Ok v -> print_endline (show_exp v) - | Error v -> print_endline v -;; \ No newline at end of file diff --git a/OcamlOOP/demos/dune b/OcamlOOP/demos/dune deleted file mode 100644 index 11a1aa4c5..000000000 --- a/OcamlOOP/demos/dune +++ /dev/null @@ -1,53 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name demo_fact) - (public_name demo_fact) - (modules demo_fact) - (libraries OcamlOOP.Lib) - (preprocess - (pps ppx_show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demo_obj) - (public_name demo_obj) - (modules demo_obj) - (libraries OcamlOOP.Lib) - (preprocess - (pps ppx_show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - ) - -(executable - (name demo_obj1) - (public_name demo_obj1) - (modules demo_obj1) - (libraries OcamlOOP.Lib) - (preprocess - (pps ppx_show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - ) - -(executable - (name demo) - (public_name demo) - (modules demo) - (libraries OcamlOOP.Lib stdio) - (preprocess - (pps ppx_show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx)) - ) - -(cram - (deps %{bin:demo_fact} %{bin:demo_obj} %{bin:demo_obj1} %{bin:demo})) \ No newline at end of file diff --git a/OcamlOOP/demos/test.t b/OcamlOOP/demos/test.t deleted file mode 100644 index d83b6153a..000000000 --- a/OcamlOOP/demos/test.t +++ /dev/null @@ -1,79 +0,0 @@ - $ dune exec demo_fact - LetRec - (Pdecl - (PVal (Id ("fact")), - Fun - (PVal (Id ("x")), - IfThenElse - (BinOp (Eq, EVal (Id ("x")), EConst (Int (0))), EConst (Int (1)), - BinOp - (Asterisk, EVal (Id ("x")), - App (EVal (Id ("fact")), BinOp (Sub, EVal (Id ("x")), EConst (Int (1)))))))), - EConst (Unit)) - $ dune exec demo_obj - Let - (Pdecl - (PVal (Id ("minmax")), - Fun - (PVal (Id ("x")), - Fun - (PVal (Id ("y")), - IfThenElse - (BinOp (Lt, EVal (Id ("x")), EVal (Id ("y"))), - Eobject - (Pany, - [Omethod (Public, PVal (Id ("min")), EVal (Id ("x"))); - Omethod (Public, PVal (Id ("max")), EVal (Id ("y")))]), - Eobject - (Pany, - [Omethod (Public, PVal (Id ("min")), EVal (Id ("y"))); - Omethod (Public, PVal (Id ("max")), EVal (Id ("x")))]))))), - EConst (Unit)) - $ dune exec demo_obj1 - Let - (Pdecl - (PVal (Id ("p")), - Eobject - (PVal (Id ("s")), - [Oval (PVal (Id ("x")), EConst (Int (5))); - Omethod (Private, PVal (Id ("get_x")), EVal (Id ("x"))); - Omethod - (Public, PVal (Id ("print")), - App - (EVal (Id ("print_int")), Esend (EVal (Id ("s")), PVal (Id ("get_x")))))])), - EConst (Unit)) - - $ cat << EOF | dune exec demo - - > let sum x y = x + y ;; - > - > let is_ten n = - > match n with - > | 10 -> true - > | _ -> false - > ;; - > - > let incr x = x + 1 ;; - > EOF - Let - (Pdecl - (PVal (Id ("sum")), - Fun - (PVal (Id ("x")), - Fun (PVal (Id ("y")), BinOp (Plus, EVal (Id ("x")), EVal (Id ("y")))))), - EConst (Unit)) - Let - (Pdecl - (PVal (Id ("is_ten")), - Fun - (PVal (Id ("n")), - Match - (EVal (Id ("n")), - [(PConst (Int (10)), EConst (Bool (true))); - (PVal (Id ("_")), EConst (Bool (false)))]))), - EConst (Unit)) - Let - (Pdecl - (PVal (Id ("incr")), - Fun (PVal (Id ("x")), BinOp (Plus, EVal (Id ("x")), EConst (Int (1))))), - EConst (Unit)) - diff --git a/OcamlOOP/dune b/OcamlOOP/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/OcamlOOP/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/OcamlOOP/dune-project b/OcamlOOP/dune-project deleted file mode 100644 index b749f66de..000000000 --- a/OcamlOOP/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name OcamlOOP) - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/OcamlOOP/lib/ast.ml b/OcamlOOP/lib/ast.ml deleted file mode 100644 index ff8673223..000000000 --- a/OcamlOOP/lib/ast.ml +++ /dev/null @@ -1,96 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type ident = Id of string [@@deriving eq, show { with_path = false }] - -let p_id s = Id s - -type private_flag = - | Private - | Public -[@@deriving eq, show { with_path = false }] - -type closed_flag = - | Closed - | Open -[@@deriving eq, show { with_path = false }] - -type bin_op = - | Asterisk - | Divider - | Plus - | Sub - | Eq - | Neq - | Lt - | Ltq - | Gt - | Gtq - | And - | Or -[@@deriving eq, show { with_path = false }] - -type unary_op = - | Minus - | Not -[@@deriving eq, show { with_path = false }] - -type const = - | Int of int - | Bool of bool - | Nil - | Unit -[@@deriving eq, show { with_path = false }] - -type ptrn = - | PConst of const - | PVal of ident - | Pcons of ptrn * ptrn - | Pany (* the pattern _ *) -[@@deriving eq, show { with_path = false }] - -type exp = - | EConst of const - | UnaryOp of unary_op * exp - | BinOp of bin_op * exp * exp - | EVal of ident - | Fun of ptrn * exp - | Let of decl * exp - | LetRec of decl * exp - | Match of exp * (ptrn * exp) list - | IfThenElse of exp * exp * exp - | App of exp * exp - | Eobject of ptrn * field list - | Esend of exp * ptrn (* not sure *) -[@@deriving eq, show { with_path = false }] - -and decl = Pdecl of ptrn * exp - -and field = - | Oval of ptrn * exp - | Omethod of private_flag * ptrn * exp - -let c_int n = Int n -let c_bool b = Bool b -let nil = Nil -let econst c = EConst c -let pconst c = PConst c -let pcons a b = Pcons (a, b) -let pany = Pany -let pnil = PConst Nil -let eval c = EVal c -let pval c = PVal c -let un_op o e = UnaryOp (o, e) -let bin_op o l r = BinOp (o, l, r) -let pdecl i e = Pdecl (i, e) -let plet d e = Let (d, e) -let prlet d e = LetRec (d, e) -let pfun i e = Fun (i, e) -let ematch v ptrns = Match (v, ptrns) -let eapp f a = App (f, a) -let ite b t e = IfThenElse (b, t, e) -let oval p e = Oval (p, e) -let omthd f p e = Omethod (f, p, e) -let eobj s flds = Eobject (s, flds) -let esend s m = Esend (s, m) diff --git a/OcamlOOP/lib/dune b/OcamlOOP/lib/dune deleted file mode 100644 index 65b68e8c8..000000000 --- a/OcamlOOP/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name ocamlOOP_lib) - (public_name OcamlOOP.Lib) - (modules Parser Ast) - (inline_tests) - (preprocess - (pps ppx_show ppx_expect ppx_deriving.eq)) - (libraries ppx_show.runtime base angstrom) - (instrumentation - (backend bisect_ppx))) diff --git a/OcamlOOP/lib/parser.ml b/OcamlOOP/lib/parser.ml deleted file mode 100644 index bc16e5aa1..000000000 --- a/OcamlOOP/lib/parser.ml +++ /dev/null @@ -1,250 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Base -open Ast - -let is_whitespace = Char.is_whitespace -let is_digit = Char.is_digit - -let is_upper = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_lower = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_keyword = function - | "let" - | "if" - | "else" - | "fun" - | "function" - | "then" - | "rec" - | "true" - | "false" - | "match" - | "with" - | "object" - | "end" - | "val" - | "method" -> true - | _ -> false -;; - -let is_alpha c = is_upper c || is_lower c -let is_ident c = is_alpha c || Char.equal '_' c -let skip_whitespace = take_while is_whitespace -let skip_whitespace1 = take_while1 is_whitespace -let ptoken p = skip_whitespace *> p -let ptoken1 p = skip_whitespace1 *> p -let token p = skip_whitespace *> string p -let token1 p = skip_whitespace1 *> string p -let lp = token "(" -let rp = token ")" -let nil = token "[]" *> return nil -let pcons = token "::" *> return pcons -let pany = token1 "_" *> skip_whitespace1 *> return pany -let parens p = lp *> p <* rp -let sbrcts p = token "[" *> p <* token "]" -let dsmcln = token ";;" - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let rec chainr1 e op = - e >>= fun sub_e -> op >>= (fun f -> chainr1 e op >>| f sub_e) <|> return sub_e -;; - -let sign = - peek_char - >>= function - | Some '-' -> advance 1 >>| fun () -> "-" - | Some '+' -> advance 1 >>| fun () -> "+" - | Some c when is_digit c -> return "+" - | _ -> fail "Sign or digit expected" -;; - -let integer = - ptoken sign - >>= fun sign -> - take_while1 is_digit - >>= fun whole -> - let num = Stdlib.int_of_string_opt (sign ^ whole) in - match num with - | Some n -> return @@ c_int n - | None -> fail "Integer literal exceeds the range of representable integers of type int" -;; - -let boolean = - ptoken @@ take_while1 is_alpha - >>= function - | "true" -> return @@ c_bool true - | "false" -> return @@ c_bool false - | _ -> fail "not a bool" -;; - -let const = choice [ integer; boolean; nil ] -let pconst = const >>| fun p -> pconst p - -let econst = - choice - [ (integer >>| fun x -> econst x) - ; (boolean >>| fun b -> econst b) - ; (nil >>| fun n -> econst n) - ] -;; - -let ident = - ptoken peek_char - >>= (function - | Some x when Char.equal x '_' || is_lower x -> return x - | _ -> fail "fail") - >>= fun _ -> - take_while is_ident - >>= fun s -> if is_keyword s then fail "keyword" else return @@ p_id s -;; - -let eval = ident >>| eval -let pval = ident >>| pval -let fold_plist = List.fold_right ~f:(fun p1 p2 -> Ast.pcons p1 p2) ~init:Ast.pnil - -(* support @ operator ??*) -let plist = - let item = pconst <|> pval in - sbrcts @@ sep_by (token ";") item >>| fold_plist -;; - -let patern = - fix (fun _patern -> - let pat = plist <|> pval <|> pconst <|> pany in - chainl1 pat pcons) -;; - -let pfun pexpr = - token "fun" *> many1 patern - >>= fun args -> - token "->" *> pexpr - >>| fun e -> - match List.rev args with - | h :: tl -> List.fold_left ~init:(pfun h e) ~f:(fun acc x -> pfun x acc) tl - | _ -> failwith "unreachable" -;; - -let decl kws pexpr = - let exp = - skip_whitespace *> many patern - >>= fun args -> - token "=" *> pexpr - >>| fun e -> - match List.rev args with - | h :: tl -> List.fold_left ~init:(Ast.pfun h e) ~f:(fun acc x -> Ast.pfun x acc) tl - | _ -> e - in - match kws with - | _ :: [] -> token "let" *> lift2 pdecl (ptoken patern) exp - | _ -> token "let" *> token "rec" *> lift2 pdecl (ptoken patern) exp -;; - -let nrec_decl = decl ["let"] -let rec_decl = decl ["let"; "rec"] - -let plet pexpr = - lift2 plet (nrec_decl pexpr) (option (Ast.econst Unit) (token "in" *> pexpr)) -;; - -let prlet pexpr = - lift2 prlet (rec_decl pexpr) (option (Ast.econst Unit) (token "in" *> pexpr)) -;; - -(* can there be only one pattern matching? *) -let ptrn pexpr = lift2 (fun k v -> k, v) (patern <* token "->") pexpr - -let ematch pexpr = - token "match" - *> lift2 - ematch - (pexpr <* token "with") - (ptrn pexpr - <|> token "|" *> ptrn pexpr - >>= fun p -> many (token "|" *> ptrn pexpr) >>| fun ps -> p :: ps) -;; - -let ite b t e = - lift3 - ite - (token "if" *> b) - (token "then" *> t) - (option (Ast.econst Unit) (token "else" *> e)) -;; - -let eapp expr = chainl1 expr (skip_whitespace1 *> return Ast.eapp) -let bin_op chain1 e ops = chain1 e (ops >>| fun o l r -> bin_op o l r) -let lbo = bin_op chainl1 -let rbo = bin_op chainr1 -let op l = choice (List.map ~f:(fun (o, n) -> token o *> return n) l) -let mul_div = op [ "*", Asterisk; "/", Divider ] -let add_sub = op [ "+", Plus; "-", Sub ] -let cmp = op [ "<=", Ltq; "<", Lt; ">=", Gtq; ">", Gt; "=", Eq; "!=", Neq ] -let andop = op [ "&&", And ] (* & ?*) -let orop = op [ "||", Or ] (* or ?*) -let neg = op [ "not", Not; "-", Minus ] - -let pobj pexpr = - let ov = lift2 oval (token "val" *> patern) (token "=" *> pexpr) in - let helper = - skip_whitespace *> many patern - >>= fun args -> - token "=" *> pexpr - >>| fun e -> - match List.rev args with - | h :: tl -> List.fold_left ~init:(Ast.pfun h e) ~f:(fun acc x -> Ast.pfun x acc) tl - | _ -> e - in - let om = - lift3 - omthd - (token "method" *> token "private" *> return Private <|> token "method" *> return Public) - patern - helper - in - token "object" - *> lift2 eobj (option Ast.Pany (parens patern)) (many (ov <|> om) <* token "end") -;; - -(* s#{some_mthd} *) -let sinvk pexpr = lift2 esend pexpr (token "#" *> patern) - -let pexpr = - fix (fun pexpr -> - let sube = choice [ parens pexpr; econst; eval ] in - let send = sinvk sube in - let eapp = eapp (send <|> sube) in - let term = send <|> eapp <|> sube in - let term = lbo (term <|> lift2 un_op neg term) mul_div in - let term = lbo term add_sub in - let term = lbo term cmp in - let term = rbo term andop in - let term = rbo term orop in - choice - [ ite pexpr pexpr pexpr - ; plet pexpr - ; prlet pexpr - ; ematch pexpr - ; pfun pexpr - ; pobj pexpr - ; term - ]) -;; - -let del = (dsmcln <|> skip_whitespace) *> skip_whitespace -let prog = del *> many1 (pexpr <* del) -let parse = parse_string ~consume:All prog diff --git a/Parallel_execution_simulation/.gitignore b/Parallel_execution_simulation/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Parallel_execution_simulation/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Parallel_execution_simulation/.ocamlformat b/Parallel_execution_simulation/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Parallel_execution_simulation/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Parallel_execution_simulation/COPYING b/Parallel_execution_simulation/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Parallel_execution_simulation/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Parallel_execution_simulation/COPYING.CC0 b/Parallel_execution_simulation/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Parallel_execution_simulation/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Parallel_execution_simulation/COPYING.LESSER b/Parallel_execution_simulation/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Parallel_execution_simulation/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Parallel_execution_simulation/Makefile b/Parallel_execution_simulation/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Parallel_execution_simulation/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Parallel_execution_simulation/Parallel_execution_simulation.opam b/Parallel_execution_simulation/Parallel_execution_simulation.opam deleted file mode 100644 index 2af0e564d..000000000 --- a/Parallel_execution_simulation/Parallel_execution_simulation.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "Parallel execution simulation interpeter" -description: "Something is supported... but in december..." -maintainer: ["https://github.com/ALanovaya"] -authors: ["Alexandra Lanovaya"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/ALanovaya/fp2023" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "ppx_variants_conv" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} - "base" -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Parallel_execution_simulation/README.md b/Parallel_execution_simulation/README.md deleted file mode 100644 index 7549e91cd..000000000 --- a/Parallel_execution_simulation/README.md +++ /dev/null @@ -1,19 +0,0 @@ -### An implementaion of Parallel execution model mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Alexandra Lanovaya - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... \ No newline at end of file diff --git a/Parallel_execution_simulation/demos/demoParser.ml b/Parallel_execution_simulation/demos/demoParser.ml deleted file mode 100644 index e36140ba7..000000000 --- a/Parallel_execution_simulation/demos/demoParser.ml +++ /dev/null @@ -1,7 +0,0 @@ -open Parallel_execution_simulationLib -open Stdio - -let () = - let input = Stdio.In_channel.input_all stdin in - Parser.parse_prog input -;; diff --git a/Parallel_execution_simulation/demos/dune b/Parallel_execution_simulation/demos/dune deleted file mode 100644 index 0f8611ff0..000000000 --- a/Parallel_execution_simulation/demos/dune +++ /dev/null @@ -1,7 +0,0 @@ -(executable - (name demoParser) - (modules demoParser) - (public_name Parallel_execution_simulation.demos) - (libraries Parallel_execution_simulation.lib stdio) - (instrumentation - (backend bisect_ppx))) diff --git a/Parallel_execution_simulation/dune b/Parallel_execution_simulation/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/Parallel_execution_simulation/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/Parallel_execution_simulation/dune-project b/Parallel_execution_simulation/dune-project deleted file mode 100644 index 674d8b890..000000000 --- a/Parallel_execution_simulation/dune-project +++ /dev/null @@ -1,30 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(license LGPL-3.0-or-later) - -(authors "Alexandra Lanovaya") - -(maintainers "https://github.com/ALanovaya") - -(homepage "https://github.com/ALanovaya/fp2023") - -(package - (name Parallel_execution_simulation) - (synopsis "Parallel execution simulation interpeter") - (description - "Something is supported... but in december...") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - ppx_variants_conv - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - base - )) diff --git a/Parallel_execution_simulation/lib/ast.ml b/Parallel_execution_simulation/lib/ast.ml deleted file mode 100644 index 589671da3..000000000 --- a/Parallel_execution_simulation/lib/ast.ml +++ /dev/null @@ -1,19 +0,0 @@ -(** Copyright 2023-2024, Alexandra Lanovaya*) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type register = Register of string [@@deriving show] -type shared_variable = SharedVariable of string [@@deriving show] -type barrier = Barrier [@@deriving show] - -type expr = - | Constant of int - | Read of register - | ReadShared of shared_variable - | Write of shared_variable * expr - | Assign of register * expr - | Arith of string * expr * expr -[@@deriving show] - -type thread = (barrier option * expr * barrier option) list [@@deriving show] -type ast = thread list [@@deriving show] diff --git a/Parallel_execution_simulation/lib/dune b/Parallel_execution_simulation/lib/dune deleted file mode 100644 index 36abf8ce1..000000000 --- a/Parallel_execution_simulation/lib/dune +++ /dev/null @@ -1,15 +0,0 @@ -(library - (name Parallel_execution_simulationLib) - (public_name Parallel_execution_simulation.lib) - (modules ast parser) - (libraries base angstrom ppx_show.runtime) - (instrumentation - (backend bisect_ppx)) - (preprocess - (pps - ppx_variants_conv - ppx_expect - ppx_deriving.show - ppx_inline_test - ppx_enumerate)) - (inline_tests)) diff --git a/Parallel_execution_simulation/lib/parser.ml b/Parallel_execution_simulation/lib/parser.ml deleted file mode 100644 index 19c3e165b..000000000 --- a/Parallel_execution_simulation/lib/parser.ml +++ /dev/null @@ -1,131 +0,0 @@ -(** Copyright 2023-2024, Alexandra Lanovaya*) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Angstrom - -let ws = - skip_while (function - | ' ' | '\n' | '\t' | '\r' -> true - | _ -> false) -;; - -let parens p = ws *> char '(' *> p <* char ')' <* ws - -let integer = - ws - *> take_while1 (function - | '0' .. '9' -> true - | _ -> false) - <* ws - >>= fun int_str -> - match int_of_string int_str with - | exception _ -> fail "Invalid integer" - | n -> return n -;; - -let is_reserved = function - | "eax" | "ebx" | "r1" | "r2" | "r3" | "r4" | "r5" | "r6" | "r7" | "r8" | "r9" -> true - | _ -> false -;; - -let identifier = - ws - *> take_while (function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> true - | _ -> false) - <* ws -;; - -let register = - ws - *> choice - [ string "ebx" *> return (Register "ebx") - ; string "eax" *> return (Register "eax") - ; (string "r" - *> take_while1 (function - | '0' .. '9' -> true - | _ -> false) - >>= fun n -> return (Register ("r" ^ n))) - ] -;; - -let shared_variable = - identifier - >>= fun name -> - if is_reserved name then fail "Invalid identifier" else return (SharedVariable name) -;; - -let constant = integer >>| fun i -> Constant i -let barrier = ws *> string "smp" <* ws >>| fun _ -> Barrier - -let expr = - fix (fun expr -> - choice - [ parens expr - ; lift2 (fun r e -> Assign (r, e)) (register <* ws) (string "<-" *> expr <* ws) - ; lift2 - (fun sv e -> Write (sv, e)) - (shared_variable <* ws) - (string "<-" *> expr <* ws) - ; lift (fun r -> Read r) register - ; constant - ; lift (fun sv -> ReadShared sv) shared_variable - ]) -;; - -let guarded_expr = - choice - [ lift3 (fun b1 e b2 -> Some b1, e, Some b2) barrier expr barrier - ; lift2 (fun b e -> Some b, e, None) barrier expr - ; lift2 (fun e b -> None, e, Some b) expr barrier - ; lift (fun e -> None, e, None) expr - ] -;; - -let thread = sep_by1 (string "|||") guarded_expr -let ast = sep_by1 (char '\n') thread - -let parse str show_ast = - match parse_string ~consume:All ast str with - | Ok ast -> print_endline (show_ast ast) - | Error msg -> failwith msg -;; - -let parse_prog str = parse str Ast.show_ast - -let%expect_test "parse_register" = - parse "eax<-0" Ast.show_ast; - [%expect {| [[(None, (Ast.Assign ((Ast.Register "eax"), (Ast.Constant 0))), None)]] |}] -;; - -let%expect_test "parse_shared_variable" = - parse "x<-eax" Ast.show_ast; - [%expect - {| - [[(None, - (Ast.Write ((Ast.SharedVariable "x"), (Ast.Read (Ast.Register "eax")))), - None)] - ] |}] -;; - -let%expect_test "parse_simple_helloworld" = - parse "x<-60 ||| y<-90 smp ||| smp r1<-x ||| r2<-y" Ast.show_ast; - [%expect - {| - [[(None, (Ast.Write ((Ast.SharedVariable "x"), (Ast.Constant 60))), None); - (None, (Ast.Write ((Ast.SharedVariable "y"), (Ast.Constant 90))), - (Some Ast.Barrier)); - ((Some Ast.Barrier), - (Ast.Assign ((Ast.Register "r1"), - (Ast.ReadShared (Ast.SharedVariable "x")))), - None); - (None, - (Ast.Assign ((Ast.Register "r2"), - (Ast.ReadShared (Ast.SharedVariable "y")))), - None) - ] - ] |}] -;; diff --git a/Parallel_execution_simulation/lib/parser.mli b/Parallel_execution_simulation/lib/parser.mli deleted file mode 100644 index 778d368f1..000000000 --- a/Parallel_execution_simulation/lib/parser.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2023-2024, Alexandra Lanovaya*) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_prog : string -> unit diff --git a/PrologDatalog/.gitignore b/PrologDatalog/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/PrologDatalog/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/PrologDatalog/.ocamlformat b/PrologDatalog/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/PrologDatalog/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/PrologDatalog/COPYING b/PrologDatalog/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/PrologDatalog/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/PrologDatalog/COPYING.CC0 b/PrologDatalog/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/PrologDatalog/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/PrologDatalog/COPYING.LESSER b/PrologDatalog/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/PrologDatalog/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/PrologDatalog/Makefile b/PrologDatalog/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/PrologDatalog/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/PrologDatalog/PrologDatalog.opam b/PrologDatalog/PrologDatalog.opam deleted file mode 100644 index 513478edd..000000000 --- a/PrologDatalog/PrologDatalog.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "An interpreter for language Prolog" -description: - "Prolog interpreter on Ocaml language. Implementation of base Prolog functionality" -maintainer: ["Ilya Pogorelov"] -authors: ["Ilya Pogorelov"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/twotwozeronine/fp2023" -bug-reports: - "You can report about bugs in the code to this email: ilya_pogorelov_04@mail.ru" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/PrologDatalog/README.md b/PrologDatalog/README.md deleted file mode 100644 index 96b612fcc..000000000 --- a/PrologDatalog/README.md +++ /dev/null @@ -1,95 +0,0 @@ -### An implementaion of Prolog - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Pogorelov Ilya, ilya_pogorelov_04@mail.ru - -Features done (append only): - -- Parser - -Features in progress (and TODOs): - -- interpreter of non-recursive functions -- Interpreter of recursive functions - - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/PrologDatalog/dune b/PrologDatalog/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/PrologDatalog/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/PrologDatalog/dune-project b/PrologDatalog/dune-project deleted file mode 100644 index 1f4ce1fd4..000000000 --- a/PrologDatalog/dune-project +++ /dev/null @@ -1,35 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Ilya Pogorelov") - -(maintainers "Ilya Pogorelov") - -(bug_reports - "You can report about bugs in the code to this email: ilya_pogorelov_04@mail.ru") - -(homepage "https://github.com/twotwozeronine/fp2023") - -(package - (name PrologDatalog) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "An interpreter for language Prolog") - (description - "Prolog interpreter on Ocaml language. Implementation of base Prolog functionality") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/PrologDatalog/lib/ast.ml b/PrologDatalog/lib/ast.ml deleted file mode 100644 index 1a9db541e..000000000 --- a/PrologDatalog/lib/ast.ml +++ /dev/null @@ -1,33 +0,0 @@ -(** Copyright 2023-2024, Pogorelov Ilya *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(**base elements of Prolog*) -type name = string [@@deriving show { with_path = false }] - -type num = int [@@deriving show { with_path = false }] -type oper = string [@@deriving show { with_path = false }] -type var = string [@@deriving show { with_path = false }] - -(**Simple objects of Prolog*) -type atom = - | Name of name - | Oper of oper -[@@deriving show { with_path = false }] - -type const = - | Num of num - | Atom of atom -[@@deriving show { with_path = false }] - -(**Structures of Prolog*) -type term = - | Const of const - | Var of var - | Relation of - { atom : atom - ; terms : term list - } -[@@deriving show { with_path = false }] - -type many_term = Many_term of term list [@@deriving show { with_path = false }] diff --git a/PrologDatalog/lib/dune b/PrologDatalog/lib/dune deleted file mode 100644 index 3e04ca36d..000000000 --- a/PrologDatalog/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name prologDatalog_lib) - (public_name PrologDatalog.Lib) - (modules Ast Parser) - (inline_tests) - (libraries base angstrom) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_deriving.eq)) - (instrumentation - (backend bisect_ppx))) diff --git a/PrologDatalog/lib/parser.ml b/PrologDatalog/lib/parser.ml deleted file mode 100644 index 91f31bd49..000000000 --- a/PrologDatalog/lib/parser.ml +++ /dev/null @@ -1,245 +0,0 @@ -(** Copyright 2023-2024, Pogorelov Ilya *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Angstrom -open Ast - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -type error = [ `ParsingError of string ] - -(*application of operator to term*) -let chainl1 e op = - let rec go acc = - lift2 (fun f x -> Relation { atom = f; terms = [ acc; x ] }) op e - >>= go - <|> return acc - in - e >>= fun init -> go init -;; - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -(*declare of all need var*) -let string_of_spase = take_while is_space -let token s = string_of_spase *> string s -let dot = string_of_spase *> char '.' *> string_of_spase -let bar = string_of_spase *> char '|' *> string_of_spase -let in_bracket x = string_of_spase *> char '(' *> x <* char '(' <* string_of_spase -let sqr_brackets x = string_of_spase *> char '[' *> x <* char ']' <* string_of_spase -let in_quotes x = string_of_spase *> char '\"' *> x <* char '\"' <* string_of_spase -let parens x = char '(' *> x <* char ')' -let underscore = string_of_spase *> token "_" <* string_of_spase -let name_c x = Name x -let num_c x = Num x -let atom_c x = Atom x -let var_c x = Var x -let oper_c x = Oper x -let comma_token = token "," >>| oper_c -let semicolon = token ";" >>| oper_c -let sign_rule = token ":-" >>| oper_c -let not = token "\\+" >>| oper_c -let eqq = token "==" <|> token "=" >>| oper_c -let assign = token "is" >>| oper_c - -let aryth_oper = - token "+" - <|> token "-" - <|> token "*" - <|> token "/" - <|> token "**" - <|> token "//" - <|> token "<" - <|> token ">" - >>| oper_c -;; - -let is_letter_number = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> true - | _ -> false -;; - -let is_letter_cap = function - | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_letter_lower = function - | 'a' .. 'z' -> true - | _ -> false -;; - -let is_number = function - | '0' .. '9' -> true - | _ -> false -;; - -let isnot_letter_number = function - | '#' - | '$' - | '&' - | '*' - | '+' - | '-' - | '.' - | '/' - | ':' - | '<' - | '=' - | '>' - | '?' - | '@' - | '^' - | '~' -> true - | _ -> false -;; - -let is_anything c = is_letter_number c || isnot_letter_number c - -(*declare simple parsers*) -(*first case: base name of atom (starts with lowercase letter) or '!'; second case: name of atom is "string"; third case: empty atom*) -let atom = - string_of_spase - *> (satisfy (function - | 'a' .. 'z' | '!' -> true - | _ -> false) - <|> satisfy isnot_letter_number) - >>= (fun ch -> take_while is_letter_number >>| fun str -> String.make 1 ch ^ str) - >>| name_c - <|> (string_of_spase *> in_quotes (take_while is_anything <|> take_while is_space) - >>= fun str -> return (String.concat str [ "\""; "\"" ]) >>| name_c) - <|> (token "[]" >>| name_c) -;; - -(*first case: atom; second case: number*) -let const = - atom - >>| atom_c - <|> (string_of_spase *> take_while1 is_number >>| int_of_string >>| num_c) -;; - -(*first case: anonymous variable; second case: base name of variable (starts with uppercase letter)*) -let var = - underscore - >>| var_c - <|> string_of_spase - *> (satisfy (function - | 'A' .. 'Z' | '_' -> true - | _ -> false) - >>= (fun ch -> - take_while is_letter_number >>| fun str -> String.make 1 ch ^ str) - >>| var_c) -;; - -let relation = - fix (fun relation -> - let create_relation atom terms = Relation { atom; terms } in - let const = lift (fun x -> Const x) const in - let term_with_prefix_op = - let create_relation op term = create_relation op [ term ] in - lift2 create_relation not relation - in - let term_in_func_notation = - let args = parens (sep_by1 comma_token relation) in - lift2 create_relation atom args - in - let term_in_list_notation = - fix (fun term_in_list_notation -> - let list_atom = Const (Atom (Name "[]")) in - let list_c r1 r2 = Relation { atom = Name "."; terms = [ r1; r2 ] } in - let term = - term_in_list_notation - <|> term_with_prefix_op - <|> term_in_func_notation - <|> const - <|> var - in - let items = - fix (fun items -> - lift2 list_c (term <* comma_token) items - <|> (lift2 list_c (term <* bar) term - <|> lift (fun r -> list_c r list_atom) term)) - in - sqr_brackets items) - in - in_bracket - (chainl1 - (chainl1 - (chainl1 (chainl1 (chainl1 relation aryth_oper) assign) eqq) - comma_token) - sign_rule) - <|> term_in_list_notation - <|> term_with_prefix_op - <|> term_in_func_notation - <|> const - <|> var) -;; - -let term = - chainl1 - (chainl1 (chainl1 (chainl1 (chainl1 relation aryth_oper) assign) eqq) comma_token) - sign_rule - <* dot -;; - -(*declare main parser*) -let many_term_c x = Many_term x -let parse_prolog = many1 term >>| many_term_c - -let parse_program str = - match parse_string ~consume:Consume.All parse_prolog str with - | Ok res -> Format.printf "%s" (show_many_term res) - | Error e -> Format.printf "%s" e -;; - -(**tests*) - -let%expect_test _ = - let test = - {|factorial(0, 1). factorial(N, Fact) :- N > 0, N1 is N - 1, factorial(N1, Fact1), Fact is N * Fact1.|} - in - parse_program test; - [%expect - {| - (Many_term - [Relation {atom = (Name "factorial"); - terms = [(Const (Num 0)); (Const (Num 1))]}; - Relation {atom = (Oper ":-"); - terms = - [Relation {atom = (Name "factorial"); - terms = [(Var "N"); (Var "Fact")]}; - Relation {atom = (Oper ","); - terms = - [Relation {atom = (Oper ","); - terms = - [Relation {atom = (Oper ","); - terms = - [Relation {atom = (Oper ">"); - terms = [(Var "N"); (Const (Num 0))]}; - Relation {atom = (Oper "is"); - terms = - [(Var "N1"); - Relation {atom = (Oper "-"); - terms = [(Var "N"); (Const (Num 1))]} - ]} - ]}; - Relation {atom = (Name "factorial"); - terms = [(Var "N1"); (Var "Fact1")]} - ]}; - Relation {atom = (Oper "is"); - terms = - [(Var "Fact"); - Relation {atom = (Oper "*"); - terms = [(Var "N"); (Var "Fact1")]} - ]} - ]} - ]} - ]) - |}] -;; diff --git a/PrologDatalog/lib/parser.mli b/PrologDatalog/lib/parser.mli deleted file mode 100644 index d19ca173c..000000000 --- a/PrologDatalog/lib/parser.mli +++ /dev/null @@ -1,19 +0,0 @@ -(** Copyright 2023-2024, Pogorelov Ilya *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -type error = [ `ParsingError of string ] - -val chainl1 : Ast.term Angstrom.t -> Ast.atom Angstrom.t -> Ast.term Angstrom.t - -(*Parsers*) -val atom : Ast.atom Angstrom.t -val const : Ast.const Angstrom.t -val var : Ast.term Angstrom.t -val relation : Ast.term Angstrom.t -val term : Ast.term Angstrom.t -val many_term_c : Ast.term list -> Ast.many_term -val parse_prolog : Ast.many_term Angstrom.t -val parse_program : string -> unit diff --git a/Python/.gitignore b/Python/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Python/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Python/.ocamlformat b/Python/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Python/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Python/COPYING b/Python/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Python/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Python/COPYING.CC0 b/Python/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Python/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Python/COPYING.LESSER b/Python/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Python/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Python/DONT_REMOVE_THIS_DIRECTORY.md b/Python/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/Python/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/Python/Makefile b/Python/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Python/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Python/Python.opam b/Python/Python.opam deleted file mode 100644 index be3b42fd8..000000000 --- a/Python/Python.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for Python" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Averin Pavel"] -authors: ["Averin Pavel"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Python/README.md b/Python/README.md deleted file mode 100644 index 1b8aae429..000000000 --- a/Python/README.md +++ /dev/null @@ -1,93 +0,0 @@ -### An implementaion of Python mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Averin Pavel, st107211@student.spbu.ru - -Features done (append only): - -- Factorial parser - -Features in progress (and TODOs): - -- The rest of the parser -- Interpreter - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Python/REPL.ml b/Python/REPL.ml deleted file mode 100644 index 8a5990c9e..000000000 --- a/Python/REPL.ml +++ /dev/null @@ -1,57 +0,0 @@ -(* open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; -*) diff --git a/Python/demos/demo_fact.ml b/Python/demos/demo_fact.ml deleted file mode 100644 index d92d3cb0f..000000000 --- a/Python/demos/demo_fact.ml +++ /dev/null @@ -1,18 +0,0 @@ -open Angstrom -open Python_Lib.Parser -open Python_Lib.Ast - -let test_parse = - let res = - parser - "\n\ - def factorial(x):\n\ - \ if (x == 1):\n\ - \ return 1\n\ - \ else:\n\ - \ return (x * factorial(x - 1))" - in - match res with - | Ok v -> List.iter (fun e -> print_endline (show_statement e)) v - | Error v -> print_endline v -;; diff --git a/Python/demos/dune b/Python/demos/dune deleted file mode 100644 index 94b432373..000000000 --- a/Python/demos/dune +++ /dev/null @@ -1,25 +0,0 @@ -(executable - (name demo_fact) - (public_name demo_fact) - (modules demo_fact) - (libraries Python.Lib) - (preprocess - (pps ppx_show)) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:demo_fact})) - -(executable - (name interpreter_test) - (public_name interpreter_test) - (modules interpreter_test) - (libraries Python.Lib) - (preprocess - (pps ppx_show)) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps %{bin:interpreter_test})) diff --git a/Python/demos/interpreter_test.ml b/Python/demos/interpreter_test.ml deleted file mode 100644 index aeb4a66fe..000000000 --- a/Python/demos/interpreter_test.ml +++ /dev/null @@ -1,28 +0,0 @@ -open Python_Lib.Interpreter -open Eval (Result) -open Python_Lib.Parser - -let result_fact_of_7 = - interpret - [ Function - ( Identifier "factorial" - , [ Identifier "x" ] - , [ IfElse - ( BoolOp (Equal, Variable (Identifier "x"), Const (Int 1)) - , [ Return (Const (Int 1)) ] - , [ Return - (ArithOp - ( Mul - , Variable (Identifier "x") - , FunctionCall - ( Identifier "factorial" - , [ ArithOp (Sub, Variable (Identifier "x"), Const (Int 1)) ] - ) )) - ] ) - ] ) - ; Expression - (FunctionCall - ( Identifier "print" - , [ FunctionCall (Identifier "factorial", [ Const (Int 10) ]) ] )) - ] -;; diff --git a/Python/demos/test.t b/Python/demos/test.t deleted file mode 100644 index 65f675ad0..000000000 --- a/Python/demos/test.t +++ /dev/null @@ -1,19 +0,0 @@ - $ dune exec demo_fact - (Function ((Identifier "factorial"), [(Identifier "x")], - [(IfElse ((BoolOp (Equal, (Variable (Identifier "x")), (Const (Int 1)))), - [(Return (Const (Int 1)))], - [(Return - (ArithOp (Mul, (Variable (Identifier "x")), - (FunctionCall ((Identifier "factorial"), - [(ArithOp (Sub, (Variable (Identifier "x")), (Const (Int 1)) - )) - ] - )) - ))) - ] - )) - ] - )) - - $ dune exec interpreter_test - 3628800 diff --git a/Python/dune b/Python/dune deleted file mode 100644 index 05335fb59..000000000 --- a/Python/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Python.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Python/dune-project b/Python/dune-project deleted file mode 100644 index 05024478e..000000000 --- a/Python/dune-project +++ /dev/null @@ -1,35 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Averin Pavel") - -(maintainers "Averin Pavel") - - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Python) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for Python") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Python/lib/ast.ml b/Python/lib/ast.ml deleted file mode 100644 index ca0501b55..000000000 --- a/Python/lib/ast.ml +++ /dev/null @@ -1,58 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(*Standart data types: integers, strings, lists*) -type value = - | Int of int - | String of string - | List of value list - | Bool of bool - | None -[@@deriving eq, show { with_path = false }] - -(*Standart arithmetic operations *) -type arith_op = - | Add - | Sub - | Mul - | Div - | Mod -[@@deriving eq, show { with_path = false }] - -(*Funcions' name & args' name*) -type identifier = Identifier of string [@@deriving eq, show { with_path = false }] - -(*Standart boolean operators*) -type bool_op = - | And - | Or - | Equal - | NotEqual - | GreaterOrEqual - | Greater - | LessOrEqual - | Less -[@@deriving eq, show { with_path = false }] - -(*Standart expressions*) -type expression = - | Const of value - | Variable of identifier - | ArithOp of arith_op * expression * expression - | BoolOp of bool_op * expression * expression - | FunctionCall of identifier * expression list -[@@deriving eq, show { with_path = false }] - -type statement = - | Expression of expression - | IfElse of expression * statement list * statement list - | While of expression * statement list - | Assign of expression * expression - | Return of expression - | Function of identifier * identifier list * statement list -[@@deriving eq, show { with_path = false }] - -type flag = - | No - | Return_f diff --git a/Python/lib/dune b/Python/lib/dune deleted file mode 100644 index f7dfe5976..000000000 --- a/Python/lib/dune +++ /dev/null @@ -1,10 +0,0 @@ -(library - (name python_Lib) - (public_name Python.Lib) - (modules Ast Parser Interpreter tests) - (libraries ppx_show.runtime base angstrom) - (inline_tests) - (preprocess - (pps ppx_inline_test ppx_deriving.show ppx_deriving.eq ppx_expect)) - (instrumentation - (backend bisect_ppx))) diff --git a/Python/lib/interpreter.ml b/Python/lib/interpreter.ml deleted file mode 100644 index 0b086b147..000000000 --- a/Python/lib/interpreter.ml +++ /dev/null @@ -1,333 +0,0 @@ -(** Copyright 2021-2022, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Format - -module type MONAD = sig - type 'a t - - val return : 'a -> 'a t - val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t - - (* A synonym for >>= *) - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t -end - -module type MONADERROR = sig - include MONAD - - val error : string -> 'a t -end - -module Result : MONADERROR with type 'a t = ('a, string) result = struct - type 'a t = ('a, string) Result.t - - let ( >>= ) = Result.bind - let return = Result.ok - let ( let* ) = ( >>= ) - let error = Result.error -end - -module Eval (M : MONADERROR) = struct - open M - - (* Utility functions *) - let rec fold_left func init = function - | [] -> return init - | hd :: tl -> func init hd >>= fun init -> fold_left func init tl - ;; - - let rec map1 f = function - | [] -> return [] - | h :: tl -> f h >>= fun c -> map1 f tl >>= fun lst -> return (c :: lst) - ;; - - (* Environment symbols *) - type var_symb = - { identifier : identifier - ; value : value - } - - type function_symb = - { identifier : identifier - ; params : identifier list - ; body : statement list - } - (* Environments *) - - type environment = - { id : identifier - ; local_envs : environment list - ; functions : function_symb list - ; flag : flag - ; return_v : value - ; vars : var_symb list - ; vals_to_print : value list - } - - let local_env : environment = - { id = Identifier "local" - ; local_envs = [] - ; functions = [] - ; flag = No - ; return_v = None - ; vars = [] - ; vals_to_print = [] - } - ;; - - let global_env = - { id = Identifier "global" - ; vars = [] - ; local_envs = [ local_env ] - ; functions = [] - ; flag = No - ; return_v = None - ; vals_to_print = [] - } - ;; - - (* Environment related functions for variables *) - - let var_in_env i env = List.exists (fun (x : var_symb) -> x.identifier = i) env.vars - - let change_var i new_value env = - let new_vars = - List.map - (fun (x : var_symb) -> - if x.identifier = i then { x with value = new_value } else x) - env.vars - in - { env with vars = new_vars } - ;; - - let change_or_add_var env (x : var_symb) = - match var_in_env x.identifier env with - | true -> change_var x.identifier x.value env - | false -> { env with vars = x :: env.vars } - ;; - - let change_or_add_var_list = List.fold_left change_or_add_var - let get_var i env = List.find (fun (x : var_symb) -> x.identifier = i) env.vars - - (* Environment related functions for functions *) - - let func_in_env i env = - List.exists (fun (a : function_symb) -> i = a.identifier) env.functions - ;; - - let change_func new_func env = - let new_funcs = - List.map - (fun (x : function_symb) -> - if x.identifier = new_func.identifier - then { x with body = new_func.body; params = new_func.params } - else x) - env.functions - in - { env with functions = new_funcs } - ;; - - let change_or_add_func (x : function_symb) env = - match func_in_env x.identifier env with - | true -> change_func x env - | false -> { env with functions = x :: env.functions } - ;; - - let get_func i env = - List.find (fun (x : function_symb) -> x.identifier = i) env.functions - ;; - - (* Miscellaneous *) - let pack_to_string = function - | String a -> a - | Int a -> Int.to_string a - | Bool a -> Bool.to_string a - | _ -> "Interpretation Error" - ;; - - let rec print_list = function - | [] -> () - | e :: l -> - print_string e; - print_string " "; - print_list l - ;; - - let combine_args_and_params args (params : value list) = - List.map (fun x -> { identifier = fst x; value = snd x }) (List.combine args params) - ;; - - (* Debugging & Testing functions *) - - let get_str_from_identifier (Identifier i) = i - - let rec print_funcs = function - | [] -> () - | func :: remaining_functions -> - print_string (get_str_from_identifier func.identifier); - print_string " "; - print_funcs remaining_functions - ;; - - let rec print_vars = function - | [] -> () - | (var : var_symb) :: (remaining_vars : var_symb list) -> - print_string (get_str_from_identifier var.identifier); - print_string " "; - print_vars remaining_vars - ;; - - (* Main functions *) - - type dispatch = - { i_expr : dispatch -> environment -> expression -> value t - ; i_stmt : dispatch -> environment -> statement -> environment t - } - - let i_exp_or_stmt = - let rec i_expr (exp_or_stmt : dispatch) (env : environment) exp = - let rec apply env body = - if env.flag == Return_f - then return env.return_v - else ( - match body with - | [] -> return None - | hd :: tl -> - let* a = exp_or_stmt.i_stmt exp_or_stmt env hd in - apply a tl) - in - match exp with - | Const a -> return a - | ArithOp (Add, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - (match a, b with - | Int a1, Int b1 -> return (Int (a1 + b1)) - | _ -> error "unexpected type") - | ArithOp (Sub, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - (match a, b with - | Int a1, Int b1 -> return (Int (a1 - b1)) - | _ -> error "unexpected type") - | ArithOp (Div, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - (match a, b with - | _, Int b1 when b1 = 0 -> error "0 Division Error" - | Int a1, Int b1 -> return (Int (a1 / b1)) - | _ -> error "unexpected type") - | ArithOp (Mul, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - (match a, b with - | Int a1, Int b1 -> return (Int (a1 * b1)) - | _ -> error "unexpected type") - | BoolOp (Equal, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a = b)) - | BoolOp (NotEqual, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a != b)) - | BoolOp (Less, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a < b)) - | BoolOp (LessOrEqual, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a <= b)) - | BoolOp (Greater, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a > b)) - | BoolOp (GreaterOrEqual, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a >= b)) - | BoolOp (And, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a = b)) - | BoolOp (Or, a, b) -> - let* a = i_expr exp_or_stmt env a in - let* b = i_expr exp_or_stmt env b in - return (Bool (a = Bool true || b = Bool true)) - | Variable i -> - (match var_in_env i env with - | true -> return (get_var i env).value - | false -> error "undefined Variable") - | FunctionCall (identifier, exp_list) -> - (match identifier with - | Identifier "print" -> - let rec print_exp_list = function - | [] -> return None - | exp :: tl -> - let* value = i_expr exp_or_stmt env exp in - let () = Printf.printf "%s" (pack_to_string value) in - print_exp_list tl - in - (match exp_list with - | [] -> return None - | _ -> print_exp_list exp_list) - | _ -> - (match func_in_env identifier env with - | false -> error "undefined Function" - | true -> - let* x = map1 (fun x -> i_expr exp_or_stmt env x) exp_list in - apply - { (change_or_add_var_list - env - (combine_args_and_params (get_func identifier env).params x)) - with - id = Identifier "local" - ; local_envs = [ { local_env with vars = env.vars } ] - ; functions = [ get_func identifier env ] - } - (get_func identifier env).body)) - | _ -> error "wip" - in - let rec i_stmt (i_exp_or_stmt : dispatch) (env : environment) = function - | Expression exp -> - let* some_val = i_expr i_exp_or_stmt env exp in - return env - | Return exp -> - let* value = i_exp_or_stmt.i_expr i_exp_or_stmt env exp in - return { env with flag = Return_f; return_v = value } - | IfElse (guard, ifBranch, elseBranch) -> - let* res = i_expr i_exp_or_stmt env guard in - let get_env env = fold_left (i_exp_or_stmt.i_stmt i_exp_or_stmt) env in - (match res with - | Bool true -> get_env env ifBranch - | Bool false -> get_env env elseBranch - | _ -> error "failed to interpred the guard") - | Assign (l, r) -> - (match l with - | Variable identifier -> - let* value = i_exp_or_stmt.i_expr i_exp_or_stmt env r in - return (change_or_add_var env { identifier; value }) - | _ -> error "Left-hand side operator is not a variable") - | Function (i, some_params, some_body) -> - let new_func_env = { identifier = i; params = some_params; body = some_body } in - return (change_or_add_func new_func_env env) - | _ -> error "wip" - in - { i_expr; i_stmt } - ;; - - let interpret_exp (e : expression) global_env = - i_exp_or_stmt.i_expr i_exp_or_stmt global_env e - ;; - - let get_env global_env = fold_left (i_exp_or_stmt.i_stmt i_exp_or_stmt) global_env - - let interpret = - let env = global_env in - get_env env - ;; -end diff --git a/Python/lib/interpreter.mli b/Python/lib/interpreter.mli deleted file mode 100644 index f34088c3e..000000000 --- a/Python/lib/interpreter.mli +++ /dev/null @@ -1,83 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -module type MONAD = sig - type 'a t - - val return : 'a -> 'a t - val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t -end - -module type MONADERROR = sig - type 'a t - - val return : 'a -> 'a t - val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t - val error : string -> 'a t -end - -module Result : sig - type 'a t = ('a, string) result - - val return : 'a -> 'a t - val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t - val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t - val error : string -> 'a t -end - -module Eval : functor (M : MONADERROR) -> sig - val fold_left : ('a -> 'b -> 'a M.t) -> 'a -> 'b list -> 'a M.t - val map1 : ('a -> 'b M.t) -> 'a list -> 'b list M.t - - type var_symb = - { identifier : Ast.identifier - ; value : Ast.value - } - - type function_symb = - { identifier : Ast.identifier - ; params : Ast.identifier list - ; body : Ast.statement list - } - - type environment = - { id : Ast.identifier - ; local_envs : environment list - ; functions : function_symb list - ; flag : Ast.flag - ; return_v : Ast.value - ; vars : var_symb list - ; vals_to_print : Ast.value list - } - - val local_env : environment - val global_env : environment - val var_in_env : Ast.identifier -> environment -> bool - val change_var : Ast.identifier -> Ast.value -> environment -> environment - val change_or_add_var : environment -> var_symb -> environment - val change_or_add_var_list : environment -> var_symb list -> environment - val get_var : Ast.identifier -> environment -> var_symb - val func_in_env : Ast.identifier -> environment -> bool - val change_func : function_symb -> environment -> environment - val change_or_add_func : function_symb -> environment -> environment - val get_func : Ast.identifier -> environment -> function_symb - val pack_to_string : Ast.value -> string - val print_list : string list -> unit - val combine_args_and_params : Ast.identifier list -> Ast.value list -> var_symb list - val get_str_from_identifier : Ast.identifier -> string - val print_funcs : function_symb list -> unit - val print_vars : var_symb list -> unit - - type dispatch = - { i_expr : dispatch -> environment -> Ast.expression -> Ast.value M.t - ; i_stmt : dispatch -> environment -> Ast.statement -> environment M.t - } - - val i_exp_or_stmt : dispatch - val interpret_exp : Ast.expression -> environment -> Ast.value M.t - val get_env : environment -> Ast.statement list -> environment M.t - val interpret : Ast.statement list -> environment M.t -end diff --git a/Python/lib/parser.ml b/Python/lib/parser.ml deleted file mode 100644 index 076581ed6..000000000 --- a/Python/lib/parser.ml +++ /dev/null @@ -1,370 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Modules *) -open Angstrom -open Ast - -(* Taken names of expression & statements *) -let is_banned = function - | "and" - | "or" - | "true" - | "false" - | "return" - | "if" - | "else" - | "while" - | "def" - | "class" - | "lambda" -> true - | _ -> false -;; - -(* Checkers *) -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_sign = function - | '-' -> true - | _ -> false -;; - -let is_valid_func_first_char = function - | 'a' .. 'z' | 'A' .. 'Z' -> true - | _ -> false -;; - -let is_eol = function - | '\n' -> true - | _ -> false -;; - -let is_whitespace = function - | ' ' -> true - | _ -> false -;; - -let is_stmt_sep = function - | '\n' | ';' | ' ' | '\t' -> true - | _ -> false -;; - -let is_variable = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> true - | _ -> false -;; - -let is_quotes = function - | '\"' -> true - | _ -> false -;; - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -(* Skippers *) -let skip_whitespace = skip_while is_whitespace -let between t1 t2 e1 = t1 *> skip_whitespace *> e1 <* skip_whitespace <* t2 -let round_brackets e1 = between (string "(") (string ")") e1 -let skip_stmt_sep = skip_while is_stmt_sep - -(* Takers *) -let take_number = take_while is_digit -let take_string = take_till is_quotes -let take_variable = take_while is_variable -let take_sign = take_while is_sign -let token t = skip_whitespace *> string t -let t_return = token "return" -let t_def = token "def" -let t_mul = token "*" -let t_eq = token "==" -let t_not_eq = token "!=" -let t_quote = token "\"" -let t_div = token "/" -let t_assign = token "=" -let t_mod = token "%" -let t_comma = token "," -let t_sub = token "-" -let t_add = token "+" -let t_if = token "if" -let t_else = token "else" -let t_while = token "while" -let t_and = token "and" -let t_greater = token ">" -let t_less_equal = token "<=" -let t_greater_equal = token ">=" -let t_less = token "<" -let t_or = token "or" - -(*Builders*) -let exp_add e1 e2 = ArithOp (Add, e1, e2) -let exp_sub e1 e2 = ArithOp (Sub, e1, e2) -let exp_mul e1 e2 = ArithOp (Mul, e1, e2) -let exp_div e1 e2 = ArithOp (Div, e1, e2) -let exp_mod e1 e2 = ArithOp (Mod, e1, e2) -let exp_eq e1 e2 = BoolOp (Equal, e1, e2) -let exp_not_eq e1 e2 = BoolOp (NotEqual, e1, e2) -let stmt_expression e = Expression e -let stmt_func i el sl = Function (i, el, sl) -let stmt_if_else e sl1 sl2 = IfElse (e, sl1, sl2) -let stmt_return e = Return e -let stmt_assign e1 e2 = Assign (e1, e2) -let stmt_while e sl = While (e, sl) -let exp_func_call i el = FunctionCall (i, el) -let exp_and e1 e2 = BoolOp (And, e1, e2) -let exp_or e1 e2 = BoolOp (Or, e1, e2) -let exp_greater e1 e2 = BoolOp (Greater, e1, e2) -let exp_less e1 e2 = BoolOp (Less, e1, e2) -let exp_greater_equal e1 e2 = BoolOp (GreaterOrEqual, e1, e2) -let exp_less_equal e1 e2 = BoolOp (LessOrEqual, e1, e2) - -(* Lifters *) -let lift_func_call = lift2 exp_func_call -let lift_return = lift stmt_return -let lift_func = lift3 stmt_func -let lift_assign = lift2 stmt_assign -let lift_if_else = lift3 stmt_if_else -let lift_expression = lift stmt_expression -let lift_while = lift2 stmt_while - -(* Parsers *) -let p_mul = t_mul *> return exp_mul -let p_div = t_div *> return exp_div -let p_mod = t_mod *> return exp_mod -let p_sub = t_sub *> return exp_sub -let p_add = t_add *> return exp_add -let p_assign el1 = lift_assign (el1 <* t_assign) el1 -let p_eq = t_eq *> return exp_eq -let p_not_eq = t_not_eq *> return exp_not_eq -let p_and = t_and *> return exp_and -let p_or = t_or *> return exp_or -let p_greater = t_greater *> return exp_greater -let p_gr_eq = t_greater_equal *> return exp_greater_equal -let p_less = t_less *> return exp_less -let p_less_eq = t_less_equal *> return exp_less_equal - -let p_integer = - take_sign - >>= fun sign -> take_number >>= fun x -> return (Const (Int (int_of_string (sign ^ x)))) -;; - -let p_string = t_quote *> take_string <* t_quote >>= fun x -> return (Const (String x)) - -let p_variable = - take_variable - >>= function - | x when not (is_banned x) -> return (Variable (Identifier x)) - | _ -> fail "can't name a variable with a taken word" -;; - -let p_if_else el sl = - let exp = t_if *> skip_whitespace *> el <* char ':' <* skip_stmt_sep in - lift_if_else - exp - (sl <* skip_stmt_sep) - (t_else *> char ':' *> sl <* skip_stmt_sep <|> return []) -;; - -let p_identifier = - skip_whitespace *> take_variable - <|> skip_whitespace *> take_variable - >>= function - | x when not (is_banned x) -> return (Identifier x) - | _ -> fail "can't name a variable with a taken word" -;; - -let p_func_call el = lift_func_call p_identifier (round_brackets el) - -let p_return exp = - let e = t_return *> skip_whitespace *> exp in - lift_return e -;; - -let p_func el sl = - let id = t_def *> skip_whitespace *> p_identifier <* skip_stmt_sep in - lift_func - id - (round_brackets el <* char ':' <* skip_stmt_sep <|> return []) - (sl <* skip_stmt_sep) -;; - -let p_while e sl = - let exp = t_while *> skip_whitespace *> e <* char ':' <* skip_stmt_sep in - lift_while exp sl <* skip_stmt_sep -;; - -(* WIP *) -let p_lambda el sl = fail "WIP" - -(* Multiple parsers *) -let mp_high_pr_op = p_mul <|> p_div <|> p_mod -let mp_low_pr_op = p_add <|> p_sub - -let gp_comparison_ops = - p_eq <|> p_not_eq <|> p_gr_eq <|> p_less_eq <|> p_greater <|> p_less -;; - -let gp_logic_ops = p_and <|> p_or - -type dispatch = - { p_expression : dispatch -> expression t - ; p_statement : dispatch -> statement t - } - -let p_exp_or_stmt = - let p_expression exp_or_stmt = - fix (fun p_expression -> - let expression_list = sep_by t_comma p_expression in - let statement_list = sep_by skip_stmt_sep (exp_or_stmt.p_statement exp_or_stmt) in - let identifier_list = sep_by t_comma p_identifier in - let next_char = - skip_whitespace *> peek_char_fail - >>= function - | c when is_valid_func_first_char c -> - p_func_call expression_list - <|> p_lambda identifier_list statement_list - <|> p_variable - | c when is_digit c || is_sign c -> p_integer - | '(' -> round_brackets p_expression - | '\"' -> p_string - | _ -> fail "unexpected input" - in - List.fold_left - chainl1 - next_char - [ mp_high_pr_op; mp_low_pr_op; gp_comparison_ops; gp_logic_ops ]) - in - let p_statement exp_or_stmt = - fix (fun p_statement -> - let statement_list = sep_by skip_stmt_sep p_statement in - let identifier_list = sep_by t_comma p_identifier in - let ps_expression = lift stmt_expression (exp_or_stmt.p_expression exp_or_stmt) in - let ps_assign = p_assign (exp_or_stmt.p_expression exp_or_stmt) in - let ps_return = p_return (exp_or_stmt.p_expression exp_or_stmt) in - let ps_if_else = p_if_else (exp_or_stmt.p_expression exp_or_stmt) statement_list in - let ps_func = p_func identifier_list statement_list in - let ps_while = p_while (exp_or_stmt.p_expression exp_or_stmt) statement_list in - skip_stmt_sep - *> (ps_func - <|> ps_assign - <|> ps_return - <|> ps_if_else - <|> ps_expression - <|> ps_while)) - in - { p_expression; p_statement } -;; - -(* function that runs the given parser on a string *) -let parse p s = parse_string ~consume:All p s - -(* A parser for Python *) -let pyParser = sep_by skip_stmt_sep (p_exp_or_stmt.p_statement p_exp_or_stmt) -let parser s = parse pyParser s - -(* Tests *) -let%test _ = - parser "print(\"Hello World\")" - = Ok - [ Expression (FunctionCall (Identifier "print", [ Const (String "Hello World") ])) ] -;; - -let%test _ = parse pyParser "1" = Ok [ Expression (Const (Int 1)) ] - -let%test _ = - parse pyParser "if y == 3:\n x = 0" - = Ok - [ IfElse - ( BoolOp (Equal, Variable (Identifier "y"), Const (Int 3)) - , [ Assign (Variable (Identifier "x"), Const (Int 0)) ] - , [] ) - ] -;; - -let%test _ = - parse pyParser "myFunction(x)" - = Ok - [ Expression (FunctionCall (Identifier "myFunction", [ Variable (Identifier "x") ])) - ] -;; - -let%test _ = - parse pyParser "def testFunction(x):\n x = 1\n return x + 1" - = Ok - [ Function - ( Identifier "testFunction" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "x"), Const (Int 1)) - ; Return (ArithOp (Add, Variable (Identifier "x"), Const (Int 1))) - ] ) - ] -;; - -let%test _ = - parse pyParser "while (y == 2):\n x = 2" - = Ok - [ While - ( BoolOp (Equal, Variable (Identifier "y"), Const (Int 2)) - , [ Assign (Variable (Identifier "x"), Const (Int 2)) ] ) - ] -;; - -let%test _ = - parse - pyParser - "\n\ - def factorial(x):\n\ - \ if (x == 1):\n\ - \ return 1\n\ - \ else:\n\ - \ return (x * factorial(x - 1))" - = Ok - [ Function - ( Identifier "factorial" - , [ Identifier "x" ] - , [ IfElse - ( BoolOp (Equal, Variable (Identifier "x"), Const (Int 1)) - , [ Return (Const (Int 1)) ] - , [ Return - (ArithOp - ( Mul - , Variable (Identifier "x") - , FunctionCall - ( Identifier "factorial" - , [ ArithOp (Sub, Variable (Identifier "x"), Const (Int 1)) ] - ) )) - ] ) - ] ) - ] -;; - -let%test _ = - parse pyParser "(y == 2)" - = Ok [ Expression (BoolOp (Equal, Variable (Identifier "y"), Const (Int 2))) ] -;; - -let%test _ = - parse pyParser "(y >= 2)" - = Ok [ Expression (BoolOp (GreaterOrEqual, Variable (Identifier "y"), Const (Int 2))) ] -;; - -let%test _ = - parse pyParser "(y < 2)" - = Ok [ Expression (BoolOp (Less, Variable (Identifier "y"), Const (Int 2))) ] -;; - -let%test _ = - parse pyParser "(y != 2)" - = Ok [ Expression (BoolOp (NotEqual, Variable (Identifier "y"), Const (Int 2))) ] -;; diff --git a/Python/lib/parser.mli b/Python/lib/parser.mli deleted file mode 100644 index 88387a641..000000000 --- a/Python/lib/parser.mli +++ /dev/null @@ -1,160 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val is_banned : string -> bool -val is_digit : char -> bool -val is_space : char -> bool -val is_sign : char -> bool -val is_valid_func_first_char : char -> bool -val is_eol : char -> bool -val is_whitespace : char -> bool -val is_stmt_sep : char -> bool -val is_variable : char -> bool -val is_quotes : char -> bool -val chainl1 : 'a Angstrom.t -> ('a -> 'a -> 'a) Angstrom.t -> 'a Angstrom.t -val skip_whitespace : unit Angstrom.t -val between : 'a Angstrom.t -> 'b Angstrom.t -> 'c Angstrom.t -> 'c Angstrom.t -val round_brackets : 'a Angstrom.t -> 'a Angstrom.t -val skip_stmt_sep : unit Angstrom.t -val take_number : string Angstrom.t -val take_string : string Angstrom.t -val take_variable : string Angstrom.t -val take_sign : string Angstrom.t -val token : string -> string Angstrom.t -val t_return : string Angstrom.t -val t_def : string Angstrom.t -val t_mul : string Angstrom.t -val t_eq : string Angstrom.t -val t_not_eq : string Angstrom.t -val t_quote : string Angstrom.t -val t_div : string Angstrom.t -val t_assign : string Angstrom.t -val t_mod : string Angstrom.t -val t_comma : string Angstrom.t -val t_sub : string Angstrom.t -val t_add : string Angstrom.t -val t_if : string Angstrom.t -val t_else : string Angstrom.t -val t_while : string Angstrom.t -val t_and : string Angstrom.t -val t_greater : string Angstrom.t -val t_less_equal : string Angstrom.t -val t_greater_equal : string Angstrom.t -val t_less : string Angstrom.t -val t_or : string Angstrom.t -val exp_add : Ast.expression -> Ast.expression -> Ast.expression -val exp_sub : Ast.expression -> Ast.expression -> Ast.expression -val exp_mul : Ast.expression -> Ast.expression -> Ast.expression -val exp_div : Ast.expression -> Ast.expression -> Ast.expression -val exp_mod : Ast.expression -> Ast.expression -> Ast.expression -val exp_eq : Ast.expression -> Ast.expression -> Ast.expression -val exp_not_eq : Ast.expression -> Ast.expression -> Ast.expression -val stmt_expression : Ast.expression -> Ast.statement - -val stmt_func - : Ast.identifier - -> Ast.identifier list - -> Ast.statement list - -> Ast.statement - -val stmt_if_else - : Ast.expression - -> Ast.statement list - -> Ast.statement list - -> Ast.statement - -val stmt_return : Ast.expression -> Ast.statement -val stmt_assign : Ast.expression -> Ast.expression -> Ast.statement -val stmt_while : Ast.expression -> Ast.statement list -> Ast.statement -val exp_func_call : Ast.identifier -> Ast.expression list -> Ast.expression -val exp_and : Ast.expression -> Ast.expression -> Ast.expression -val exp_or : Ast.expression -> Ast.expression -> Ast.expression -val exp_greater : Ast.expression -> Ast.expression -> Ast.expression -val exp_less : Ast.expression -> Ast.expression -> Ast.expression -val exp_greater_equal : Ast.expression -> Ast.expression -> Ast.expression -val exp_less_equal : Ast.expression -> Ast.expression -> Ast.expression - -val lift_func_call - : Ast.identifier Angstrom.t - -> Ast.expression list Angstrom.t - -> Ast.expression Angstrom.t - -val lift_return : Ast.expression Angstrom.t -> Ast.statement Angstrom.t - -val lift_func - : Ast.identifier Angstrom.t - -> Ast.identifier list Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val lift_assign - : Ast.expression Angstrom.t - -> Ast.expression Angstrom.t - -> Ast.statement Angstrom.t - -val lift_if_else - : Ast.expression Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val lift_expression : Ast.expression Angstrom.t -> Ast.statement Angstrom.t - -val lift_while - : Ast.expression Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val p_mul : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_div : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_mod : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_sub : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_add : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_assign : Ast.expression Angstrom.t -> Ast.statement Angstrom.t -val p_eq : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_not_eq : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_and : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_or : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_greater : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_gr_eq : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_less : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_less_eq : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val p_integer : Ast.expression Angstrom.t -val p_string : Ast.expression Angstrom.t -val p_variable : Ast.expression Angstrom.t - -val p_if_else - : Ast.expression Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val p_identifier : Ast.identifier Angstrom.t -val p_func_call : Ast.expression list Angstrom.t -> Ast.expression Angstrom.t -val p_return : Ast.expression Angstrom.t -> Ast.statement Angstrom.t - -val p_func - : Ast.identifier list Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val p_while - : Ast.expression Angstrom.t - -> Ast.statement list Angstrom.t - -> Ast.statement Angstrom.t - -val p_lambda : 'a -> 'b -> 'c Angstrom.t -val mp_high_pr_op : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val mp_low_pr_op : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val gp_comparison_ops : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t -val gp_logic_ops : (Ast.expression -> Ast.expression -> Ast.expression) Angstrom.t - -type dispatch = - { p_expression : dispatch -> Ast.expression Angstrom.t - ; p_statement : dispatch -> Ast.statement Angstrom.t - } - -val p_exp_or_stmt : dispatch -val parse : 'a Angstrom.t -> string -> ('a, string) result -val pyParser : Ast.statement list Angstrom.t -val parser : string -> (Ast.statement list, string) result diff --git a/Python/lib/tests.ml b/Python/lib/tests.ml deleted file mode 100644 index 08d563e75..000000000 --- a/Python/lib/tests.ml +++ /dev/null @@ -1,226 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Parser -open Interpreter -open Eval (Result) - -let unpacker (Ok x) = x -let env = global_env -let%test _ = Ok (Int 5) = interpret_exp (ArithOp (Add, Const (Int 4), Const (Int 1))) env - -let env1 = - get_env - env - [ Assign (Variable (Identifier "x"), Const (Int 6156)) - ; Assign (Variable (Identifier "x"), Const (Int 4)) - ] -;; - -let%test _ = - Ok (Int 6) - = interpret_exp - (ArithOp (Add, Const (Int 2), Variable (Identifier "x"))) - (unpacker env1) -;; - -let func_test_env1 = - get_env - env - [ Function - ( Identifier "myFunction" - , [ Identifier "x" ] - , [ Return (ArithOp (Add, Const (Int 2), Const (Int 3))) ] ) - ; Function - ( Identifier "myFunction2" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "x"), Const (Int 3)) ] ) - ] -;; - -(* print_funcs (unpacker func_test_env1).functions *) - -let%test _ = - Ok (Int 5) - = interpret_exp - (FunctionCall (Identifier "myFunction", [ Const (Int 4) ])) - (unpacker func_test_env1) -;; - -let func_test_env2 = - get_env - env - [ Function (Identifier "myFunction", [ Identifier "x" ], [ Return (Const (Int 2)) ]) - ; Function - ( Identifier "myFunction2" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "y"), Const (Int 2)); Return (Const (Int 2)) ] ) - ] -;; - -(** print_funcs (unpacker func_test_env2).functions **) - -let%test _ = - Ok (Int 4) - = interpret_exp - (ArithOp - ( Mul - , FunctionCall (Identifier "myFunction", [ Const (Int 4) ]) - , FunctionCall (Identifier "myFunction2", [ Const (Int 4) ]) )) - (unpacker func_test_env2) -;; - -let func_test_env3 = - get_env - env - [ Function (Identifier "myFunction", [ Identifier "x" ], [ Return (Const (Int 2)) ]) - ; Function - ( Identifier "myFunction2" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "y"), Const (Int 3)) - ; Return (Variable (Identifier "y")) - ] ) - ] -;; - -let%test _ = - Ok (Int 6) - = interpret_exp - (ArithOp - ( Mul - , FunctionCall (Identifier "myFunction", [ Const (Int 4) ]) - , FunctionCall (Identifier "myFunction2", [ Const (Int 4) ]) )) - (unpacker func_test_env3) -;; - -let func_test_env4 = - get_env - env - [ Function (Identifier "myFunction", [ Identifier "x" ], [ Return (Const (Int 2)) ]) - ; Function - ( Identifier "myFunction2" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "y"), Const (Int 3)) - ; Return (ArithOp (Add, Variable (Identifier "y"), Variable (Identifier "x"))) - ] ) - ] -;; - -let%test _ = - Ok (Int 9) - = interpret_exp - (ArithOp - ( Add - , FunctionCall (Identifier "myFunction", [ Const (Int 4) ]) - , FunctionCall (Identifier "myFunction2", [ Const (Int 4) ]) )) - (unpacker func_test_env4) -;; - -let func_test_env4 = - get_env - env - [ Function (Identifier "myFunction", [ Identifier "x" ], [ Return (Const (Int 2)) ]) - ; Function - ( Identifier "myFunction2" - , [ Identifier "x" ] - , [ Assign (Variable (Identifier "y"), Const (Int 3)) - ; Return (ArithOp (Add, Variable (Identifier "y"), Variable (Identifier "x"))) - ] ) - ] -;; - -let%test _ = - Ok (Int 9) - = interpret_exp - (ArithOp - ( Add - , FunctionCall (Identifier "myFunction", [ Const (Int 4) ]) - , FunctionCall (Identifier "myFunction2", [ Const (Int 4) ]) )) - (unpacker func_test_env4) -;; - -let fact_env1 = - get_env - env - [ Function - ( Identifier "factorial" - , [ Identifier "x" ] - , [ IfElse - ( BoolOp (Equal, Variable (Identifier "x"), Const (Int 1)) - , [ Return (Const (Int 1)) ] - , [ Return - (ArithOp - ( Mul - , Variable (Identifier "x") - , FunctionCall - ( Identifier "factorial" - , [ ArithOp (Sub, Variable (Identifier "x"), Const (Int 1)) ] - ) )) - ] ) - ] ) - ] -;; - -let fact_env2 = - get_env - env - [ Function - ( Identifier "factorial" - , [ Identifier "x" ] - , [ IfElse - ( BoolOp (Equal, Variable (Identifier "x"), Const (Int 1)) - , [ Return (Const (Int 1)) ] - , [ Return - (ArithOp - ( Mul - , Variable (Identifier "x") - , FunctionCall - ( Identifier "factorial" - , [ ArithOp (Sub, Variable (Identifier "x"), Const (Int 1)) ] - ) )) - ] ) - ] ) - ] -;; - -let%test _ = - Ok (Int 87178291200) - = interpret_exp - (FunctionCall (Identifier "factorial", [ Const (Int 14) ])) - (unpacker fact_env2) -;; - -let fact_and_print = - get_env - global_env - [ Function - ( Identifier "factorial" - , [ Identifier "x" ] - , [ IfElse - ( BoolOp (Equal, Variable (Identifier "x"), Const (Int 1)) - , [ Return (Const (Int 1)) ] - , [ Return - (ArithOp - ( Mul - , Variable (Identifier "x") - , FunctionCall - ( Identifier "factorial" - , [ ArithOp (Sub, Variable (Identifier "x"), Const (Int 1)) ] - ) )) - ] ) - ] ) - ; Expression - (FunctionCall - ( Identifier "print" - , [ FunctionCall (Identifier "factorial", [ Const (Int 5) ]) ] )) - ] -;; - -let%test _ = - Ok None - = interpret_exp - (FunctionCall (Identifier "print", [ Const (Int 6003) ])) - (unpacker fact_and_print) -;; diff --git a/Python/lib/tests.mli b/Python/lib/tests.mli deleted file mode 100644 index a4283f352..000000000 --- a/Python/lib/tests.mli +++ /dev/null @@ -1,3 +0,0 @@ -(** Copyright 2021-2023, Averin Pavel *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) diff --git a/Python/repl.t b/Python/repl.t deleted file mode 100644 index e69de29bb..000000000 diff --git a/README.md b/README.md index 2a47dbe59..7d5418bd3 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,13 @@ -# ФП 2023. Репо для домашек +### An implementaion of NASM micro-language -Домашки по курсу ФП 2023 оформлять **в виде пулл-реквестов к этому репо**. +License: LGPL for implementation code + WTFPL for test examples in nasm-like language -Учебная группа имеет чатик в мессенджере. Все вопросы писать туду. В личку писать нельзя -- буду банить. +Author: Vadim Yakshigulov (vadim.iakshigulov@gmail.com) -В директории `/Lambda` лежит шаблон-скелет, его нужно скопипастить и исправить под свои нужды: -- Указать автора (я должен быть способен сопоставить решение с фамилией в ведомости) -- Переименовать проект под свой мини-язык и пересобрать dune'ой. CI при сборке ожидает имя проекта, совпадающее с именем директории. **И так как имя проекта это `[a-zA-Z_]+`, то у директорий с пробелами и символами `#` шансов пройти CI нет** -- Cделать реализацию. Разработку рекомендуется вести итеративной моделью, а не водопадной. -- Изменять или удалять шаблон `Lambda` нельзя. +Features done: -Ожидается примерно следующая структура репозитория -- `/Lambda` -- шаблон проекта домашки, который редактирует только препод (вам необходимо будет его скопировать и переименовать, редактировать нельзя, удалившим его буду ставить минус баллы); -- `/CSharpExc` -- реализация мини-С# c исключениями, на основе шаблона `/Lambda`; -- `/Java` -- реализация мини-Java, снова на основе шаблона `/Lambda`; -- и т.д. +- parser +- ast +- interpreter -Для Merge Requests (a.k.a. pull requests) настроен CI, который смотрит *в какой директории* (проекте) *произошли последние изменения*, -*и именно в этой директории запускает сборку и тесты*. -Например, если поменялся файл `Lambda/src/Parser.ml`, то запустятся все тесты из директории проекта `Lambda`, -а тесты из проекта `Java` запускаться не будут. - - -Также CI собирает документацию к миниязыку и выкладывает её в https://kakadu.github.io/fp2023/doc/LANGUAGE (например, [вот так](https://kakadu.github.io/fp2023/doc/Lambda)). А ещё измеряется покрытие тестами (например, [так](https://kakadu.github.io/fp2023/cov/Lambda)). - -###### N.B. Не удаляйте директорию Lambda. Это шаблон! - -### Приёмка задач - -Решения принимаются в виде пулл-реквестов к этому репо. -* Пулл-реквесты должны проходить CI - * в том числе линтер (замечания должны исправляться); - * проверку, что автоформатирование через ocamlformat настроено и соблюдается; - * [DCO](https://github.com/apps/dco); -* В названии надо указать задачу, которую реализовывали, идентифицировать себя (фамилия, имя и курс, если возможны неоднозначности). -* К дереву абстрактного синтаксиса (AST) должны быть написаны комменты, какой конструтор за что отвечает. (Например, [как здесь](https://github.com/ocaml/ocaml/blob/4.14/parsing/parsetree.mli#L323).) -* Да, объекты и присваивание запрещены. - -Тесты нужны, чтобы убедить преподавателя, что вы таки запускали свою поделку на адекватных примерах. -Большинство тестов будут интеграционные: запустил самописный интерпретатор миниязыка и сравнил с результатом (например, с поведением интерпретатора оригинального языка). -В CI измеряeтся тестовое покрытие в процентах. Чем больше покрытие --- тем лучше. -Если код не вызывается в тестах, то либо он не нужен, либо на него не написан тест, либо (в редких случаях) это бага `ppx_bisect`, который измеряет покрытие. Чтобы покрытие тестами таки считалось, не забывайте приписывать к своим библиотекам/исполняемым файлом заклинание в dune-файлах: - - (instrumentation - (backend bisect_ppx)) - -### Подготовка окружения - -Далее инструкции по найстройки всего под GNU/Linux. Но на Windows+WSL2 тоже должно работать. - -Во-первых, нужен пакетный менеджер opam версии 2.х. С помощью него будем устанавливать OCaml 4.14.1 и необходимые пакеты. -Системный OCaml (установленный, например, из репозиториев Ubuntu) использовать не рекомендуется. - -После установки opam следует его проинициализировать и установить правильный компилятор (у меня обычно вместо SWITCHNAME используется `4.14.1+flambda`) - -Для opam >= 2.1: - - opam init --bare - opam update - opam switch create SWITCHNAME --packages=ocaml-variants.4.14.1+options,ocaml-option-flambda --yes - -Перед этим можно удалить другие switch'и, если они есть, с помощью команды `opam switch remove SWITCHNAME`. - -После установки у вас будет рабочий компилятор по-умолчанию в директории `~/.opam/SWITCHNAME/bin`. В конце установки opam вам предложит что-то добавить в ~/.bashrc, чтобы пути к компилятору автоматически подхватывались. Рекомендую это сделать. - -Если что-то пошло не так, то всегда можно указать нужный свитч руками командой, например: - - export OPAMSWITCH=SWITCHNAME && eval $(opam env) - -и затем убедиться, что путь до компилятора правильный - - $ which ocamlc - /home/username/.opam/SWITCHNAME/bin/ocamlc - -Замечание. Когда вы будете запускать VsCode, то информация об окружении opam из файла ~/.bashrc автоматически применяться не будет, потому что так это работает в UNIX системах из покон веков. Рекомендуется, либо запускать VsCode из-под opam командой `opam exec -- code`, либо прописать в месте запуска правильную переменную среды OPAMSWITCH, и запускать opam через sh: `sh -c 'eval $(opam env) && code'` - -Когда VsCode запустится, её плагин https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform слева снизу должен показать, что правильная версия компилятора подцепилась. - -В процессе работы вам также понадобится автоформаттер кода. Он устанавливается с помощью `opam install ocamlformat` в - - $ which ocamlformat - /home/username/.opam/SWITCHNAME/bin/ocamlformat - -Необходимо также в VsCode включить автоформатирование: Settings->Text Editor->Formatting->Format On Paste и Format on Save. +Including SSE instructions and syscall diff --git a/Refal5/.gitignore b/Refal5/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Refal5/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Refal5/.ocamlformat b/Refal5/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Refal5/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Refal5/COPYING b/Refal5/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Refal5/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Refal5/COPYING.CC0 b/Refal5/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Refal5/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Refal5/COPYING.LESSER b/Refal5/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Refal5/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Refal5/Lambda.opam b/Refal5/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/Refal5/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Refal5/Makefile b/Refal5/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Refal5/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Refal5/README.md b/Refal5/README.md deleted file mode 100644 index 7adf7cb08..000000000 --- a/Refal5/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Ilya Syresenkov, ilya.syresenkov@gmail.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/Refal5/REPL.ml b/Refal5/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/Refal5/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/Refal5/demos/demoAO.ml b/Refal5/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/Refal5/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/Refal5/demos/demoNO.ml b/Refal5/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/Refal5/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/Refal5/demos/demoParse.ml b/Refal5/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/Refal5/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/Refal5/demos/demo_input.txt b/Refal5/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/Refal5/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/Refal5/demos/dune b/Refal5/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/Refal5/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/Refal5/demos/interpretTests.t b/Refal5/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/Refal5/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/Refal5/demos/parsingTests.t b/Refal5/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/Refal5/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/Refal5/dune b/Refal5/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/Refal5/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/Refal5/dune-project b/Refal5/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/Refal5/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Refal5/lib/Pprintast.ml b/Refal5/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/Refal5/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/Refal5/lib/Pprintast.mli b/Refal5/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/Refal5/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/Refal5/lib/Printast.ml b/Refal5/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/Refal5/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/Refal5/lib/Printast.mli b/Refal5/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/Refal5/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/Refal5/lib/ast.mli b/Refal5/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/Refal5/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/Refal5/lib/dune b/Refal5/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/Refal5/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Refal5/lib/interpret.ml b/Refal5/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/Refal5/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/Refal5/lib/interpret.mli b/Refal5/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/Refal5/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/Refal5/lib/lambda.ml b/Refal5/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/Refal5/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/Refal5/lib/lambda.mli b/Refal5/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/Refal5/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/Refal5/lib/parser.ml b/Refal5/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/Refal5/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/Refal5/lib/parser.mli b/Refal5/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/Refal5/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/Refal5/lib/tests.ml b/Refal5/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/Refal5/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/Refal5/lib/utils.ml b/Refal5/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/Refal5/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Refal5/lib/utils.mli b/Refal5/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/Refal5/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/Refal5/repl.t b/Refal5/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/Refal5/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/Ruby/.gitignore b/Ruby/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/Ruby/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/Ruby/.ocamlformat b/Ruby/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/Ruby/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/Ruby/COPYING b/Ruby/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/Ruby/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Ruby/COPYING.CC0 b/Ruby/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/Ruby/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/Ruby/COPYING.LESSER b/Ruby/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/Ruby/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/Ruby/Makefile b/Ruby/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/Ruby/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/Ruby/README.md b/Ruby/README.md deleted file mode 100644 index 23d60578d..000000000 --- a/Ruby/README.md +++ /dev/null @@ -1,12 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in Ruby mini-language - -Author: Anna Ermolovich, brungilda364@gmail.com - -Features done: - -- Parser -- Ast diff --git a/Ruby/Ruby.opam b/Ruby/Ruby.opam deleted file mode 100644 index 5754bdb56..000000000 --- a/Ruby/Ruby.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["Anna Ermolovich"] -authors: ["Anna Ermolovich"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/Anna-er/fp2023" -bug-reports: "https://github.com/Anna-er/fp2023" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "ppx_variants_conv" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/Ruby/demos/demoParser.ml b/Ruby/demos/demoParser.ml deleted file mode 100644 index c55f438e7..000000000 --- a/Ruby/demos/demoParser.ml +++ /dev/null @@ -1,7 +0,0 @@ -open Ruby_lib -open Stdio - -let () = - let input = Stdio.In_channel.input_all stdin in - Parser.interpret_parse Parser.final_parse Ast.show_ast input -;; diff --git a/Ruby/demos/demoParser.t b/Ruby/demos/demoParser.t deleted file mode 100644 index 48f7bc594..000000000 --- a/Ruby/demos/demoParser.t +++ /dev/null @@ -1,21 +0,0 @@ - $ ./demoParser.exe <<- EOF - > def fac(n) - > if n <= 1 - > return 1 - > end - > return n * fac(n - 1) - > end - > - > puts fac(10) - > EOF - [(Func ((Id "fac"), [(Id "n")], - [(IfElse ((LessOrEqual ((Var (Id "n")), (Const (Int 1)))), - [(Returns (Const (Int 1)))], [])); - (Returns - (Mult ((Var (Id "n")), - (FuncCall ((Id "fac"), - [(Minus ((Var (Id "n")), (Const (Int 1))))])) - ))) - ] - )); - (Puts (FuncCall ((Id "fac"), [(Const (Int 10))])))] diff --git a/Ruby/demos/dune b/Ruby/demos/dune deleted file mode 100644 index 78c9b2e7a..000000000 --- a/Ruby/demos/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (name demoParser) - (modules demoParser) - (public_name ruby_demos) - (libraries ruby_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (deps ./demoParser.exe)) diff --git a/Ruby/dune b/Ruby/dune deleted file mode 100644 index 6e792640c..000000000 --- a/Ruby/dune +++ /dev/null @@ -1,8 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - diff --git a/Ruby/dune-project b/Ruby/dune-project deleted file mode 100644 index b58e1cc11..000000000 --- a/Ruby/dune-project +++ /dev/null @@ -1,35 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Anna Ermolovich") - -(maintainers "Anna Ermolovich") - -(bug_reports "https://github.com/Anna-er/fp2023") - -(homepage "https://github.com/Anna-er/fp2023") - -(package - (name Ruby) - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - ppx_variants_conv - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/Ruby/examples/facfib.rb b/Ruby/examples/facfib.rb deleted file mode 100644 index 0aad1c310..000000000 --- a/Ruby/examples/facfib.rb +++ /dev/null @@ -1,17 +0,0 @@ -def fib(n) - if n < 2 - return n - end - - return fib(n-1) + fib(n-2) -end - -def fac(n) - if n <= 1 - return 1 - end - return n * fac(n - 1) -end - -puts fib(10) -puts fac(10) diff --git a/Ruby/lib/ast.ml b/Ruby/lib/ast.ml deleted file mode 100644 index 2cd179583..000000000 --- a/Ruby/lib/ast.ml +++ /dev/null @@ -1,39 +0,0 @@ - -type value = - | Int of int - | Float of float - | Bool of bool - | Str of string - | Char of char - | Null -[@@deriving show { with_path = false }, variants] - -type id = Id of string (* Id(string) *) -[@@deriving show { with_path = false }, variants] - -type expr = - | Const of value - | Var of id - | Plus of expr * expr - | Minus of expr * expr - | Equal of expr * expr - | NotEqual of expr * expr - | LessOrEqual of expr * expr - | Mult of expr * expr (* a * b *) - | Div of expr * expr (* a \ b *) - | FuncCall of id * expr list (* f() *) - | List of expr list -[@@deriving show { with_path = false }, variants] - -type statement = - | Assign of expr * expr - | Expr of expr (* *) - | Func of id * id list * statement list (* id args stmt *) - | IfElse of expr * statement list * statement list (* expr stmt(if) stmt(else) *) - | Returns of expr - | Continue - | Break - | Puts of expr -[@@deriving show { with_path = false }, variants] - -type ast = statement list [@@deriving show { with_path = false }] \ No newline at end of file diff --git a/Ruby/lib/dune b/Ruby/lib/dune deleted file mode 100644 index da225eebe..000000000 --- a/Ruby/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name ruby_lib) - (public_name Ruby.Lib) - (modules Ast Interpret Parser utils) - (libraries base angstrom ppx_show.runtime) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_inline_test ppx_variants_conv)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) - -(library - (name tests) - (modules tests) - (libraries ruby_lib) - (preprocess - (pps ppx_expect ppx_deriving.show ppx_inline_test)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/Ruby/lib/interpret.ml b/Ruby/lib/interpret.ml deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ruby/lib/interpret.mli b/Ruby/lib/interpret.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ruby/lib/parser.ml b/Ruby/lib/parser.ml deleted file mode 100644 index 3c3a0bc41..000000000 --- a/Ruby/lib/parser.ml +++ /dev/null @@ -1,221 +0,0 @@ -open Ast -open Angstrom - -let is_whitespace = function - | ' ' | '\t' -> true - | _ -> false -;; - -let is_seporator = function - | ' ' | '\t' | '\n' | ';' -> true - | _ -> false -;; - -let is_allowed_first_letter = function - | 'a' .. 'z' | 'A' .. 'Z' | '$' | '@' | '_' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_signed = function - | '-' -> true - | _ -> false -;; - -let is_dot = function - | '.' -> true - | _ -> false -;; - -let is_quote = function - | '"' -> true - | _ -> false -;; - -let is_variable = function - | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> true - | _ -> false -;; - -let is_reserved = function - | "def" | "if" | "else" | "then" | "end" | "puts" | "return" | "break" | "next" -> true - | _ -> false -;; - -let skip_whitespace = skip_while is_whitespace -let skip_seporator = skip_while is_seporator -let between t1 t2 a = t1 *> skip_whitespace *> a <* skip_whitespace <* t2 -let round_brackets a = between (string "(") (string ")") a -let curly_brackets a = between (string "{") (string "}") a -let square_brackets a = between (string "[") (string "]") a -let vertical_bars a = between (string "|") (string "|") a -let take_number = take_while is_digit -let take_sign = take_while is_signed -let take_dot = take_while1 is_dot -let take_string = take_till is_quote -let take_variable = take_while is_variable - -let chainl1 e op = - let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in - e >>= fun init -> go init -;; - -let plus_parse = skip_whitespace *> string "+" *> return plus -let minus_parse = skip_whitespace *> string "-" *> return minus -let mult_parse = skip_whitespace *> string "*" *> return mult -let div_parse = skip_whitespace *> string "/" *> return div -let equal_parse = skip_whitespace *> string "==" *> return equal -let less_or_equal_parse = skip_whitespace *> string "<=" *> return lessorequal -let notequal_parse = skip_whitespace *> string "!=" *> return notequal -let null_parse = skip_whitespace *> string "nil" *> return (const null) -let break_parse = skip_whitespace *> string "break" *> return break -let continue_parse = skip_whitespace *> string "next" *> return continue -let true_parse = skip_whitespace *> string "true" *> return (const (bool true)) -let false_parse = skip_whitespace *> string "false" *> return (const (bool false)) - -let id_parse = - let* x = - skip_whitespace *> char '*' *> take_variable <|> skip_whitespace *> take_variable - in - match x with - | x when not (is_reserved x) -> return @@ id x - | _ -> fail "variables with reserved words are prohibited" -;; - -let var_parse = - let* x = take_variable in - match x with - | x when not (is_reserved x) -> return @@ var @@ id x - | _ -> fail "variables with reserved words are prohibited" -;; - -let integer_parse = - let e sign whole = const @@ int @@ int_of_string (sign ^ whole) in - lift2 e take_sign take_number -;; - -let float_parse = - let e sign whole dot fraction = - const @@ float @@ float_of_string (((sign ^ whole) ^ dot) ^ fraction) - in - lift4 e take_sign take_number take_dot take_number -;; - -let string_parse = - let* x = - skip_whitespace *> string "\"" *> take_string <* skip_whitespace *> string "\"" - in - return @@ const @@ str x -;; - -let func_call_parse el1 = (lift2 funccall) id_parse (round_brackets el1) - -let func_parse el1 sl1 = - let i = - skip_whitespace *> string "def" *> skip_whitespace *> id_parse <* skip_seporator - in - lift3 - func - i - (round_brackets el1 <* skip_seporator <|> return []) - (sl1 <* skip_seporator <* skip_whitespace *> string "end") -;; - -let if_else_parse el1 sl1 = - let e = skip_whitespace *> string "if" *> skip_whitespace *> el1 <* skip_seporator in - (lift3 ifelse) - e - (sl1 <* skip_seporator) - (skip_whitespace *> string "else" *> sl1 - <* skip_seporator - <|> return [] - <* skip_whitespace *> string "end") -;; - -let return_parse el1 = - let e = - skip_whitespace *> string "return" *> skip_whitespace *> (el1 <|> return (const null)) - in - (lift returns) e -;; - -let puts_parse el1 = - let e = - skip_whitespace *> string "puts" *> skip_whitespace *> (el1 <|> return (const null)) - in - (lift puts) e -;; - -let assign_parse el1 = (lift2 assign) (el1 <* skip_whitespace *> string "=") el1 - -let expression_parse = - fix - @@ fun expression_parse -> - let expression_list = sep_by (skip_whitespace *> string ",") expression_parse in - let parser = - let* x = skip_whitespace *> peek_char_fail in - match x with - | x when is_allowed_first_letter x -> - choice - [ func_call_parse expression_list - ; true_parse - ; false_parse - ; null_parse - ; var_parse - ] - | x when is_digit x || is_signed x -> float_parse <|> integer_parse - | '\"' -> string_parse - | '(' -> round_brackets expression_parse - | _ -> fail "unsupported expression is given" - in - List.fold_left - chainl1 - parser - [ choice - [ equal_parse - ; notequal_parse - ; less_or_equal_parse - ; div_parse - ; mult_parse - ; minus_parse - ; plus_parse - ] - ] -;; - -let statement_parse = - fix - @@ fun statement_parse -> - let statement_list = sep_by skip_seporator statement_parse in - let identifier_list = sep_by (skip_whitespace *> string ",") id_parse in - let ps_expression = expression_parse >>| expr in - let ps_assign = assign_parse expression_parse in - let ps_return = return_parse expression_parse in - let ps_puts = puts_parse expression_parse in - let ps_if_else = if_else_parse expression_parse statement_list in - let ps_func = func_parse identifier_list statement_list in - skip_seporator - *> choice - [ ps_assign - ; ps_return - ; ps_puts - ; break_parse - ; continue_parse - ; ps_if_else - ; ps_func - ; ps_expression - ] -;; - -let final_parse = sep_by skip_seporator statement_parse <* skip_seporator -let parse p s = parse_string ~consume:All p s - -let interpret_parse p show str = - match parse p str with - | Result.Error e -> Format.printf "Error: %s" e - | Result.Ok ast -> Format.printf "%s" (show ast) -;; diff --git a/Ruby/lib/tests.ml b/Ruby/lib/tests.ml deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ruby/lib/utils.ml b/Ruby/lib/utils.ml deleted file mode 100644 index e69de29bb..000000000 diff --git a/Ruby/lib/utils.mli b/Ruby/lib/utils.mli deleted file mode 100644 index e69de29bb..000000000 diff --git a/SchemeDelimCC/.gitignore b/SchemeDelimCC/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/SchemeDelimCC/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/SchemeDelimCC/.ocamlformat b/SchemeDelimCC/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/SchemeDelimCC/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/SchemeDelimCC/COPYING b/SchemeDelimCC/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/SchemeDelimCC/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/SchemeDelimCC/COPYING.CC0 b/SchemeDelimCC/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/SchemeDelimCC/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/SchemeDelimCC/COPYING.LESSER b/SchemeDelimCC/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/SchemeDelimCC/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/SchemeDelimCC/DONT_REMOVE_THIS_DIRECTORY.md b/SchemeDelimCC/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/SchemeDelimCC/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/SchemeDelimCC/Lambda.opam b/SchemeDelimCC/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/SchemeDelimCC/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/SchemeDelimCC/Makefile b/SchemeDelimCC/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/SchemeDelimCC/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/SchemeDelimCC/README.md b/SchemeDelimCC/README.md deleted file mode 100644 index 555826255..000000000 --- a/SchemeDelimCC/README.md +++ /dev/null @@ -1,96 +0,0 @@ -### An implementaion of Scheme delim/cc - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Rozhkov Aleksandr, alex24844@yandex.ru - -Features done (append only): - --Nothing - -Features in progress (and TODOs): - -- Parser -- interpreter of non-recursive functions -- Interpreter of recursive functions is not yet ready - - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/SchemeDelimCC/REPL.ml b/SchemeDelimCC/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/SchemeDelimCC/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/SchemeDelimCC/demos/demoAO.ml b/SchemeDelimCC/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/SchemeDelimCC/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/SchemeDelimCC/demos/demoNO.ml b/SchemeDelimCC/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/SchemeDelimCC/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/SchemeDelimCC/demos/demoParse.ml b/SchemeDelimCC/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/SchemeDelimCC/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/SchemeDelimCC/demos/demo_input.txt b/SchemeDelimCC/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/SchemeDelimCC/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/SchemeDelimCC/demos/dune b/SchemeDelimCC/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/SchemeDelimCC/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/SchemeDelimCC/demos/interpretTests.t b/SchemeDelimCC/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/SchemeDelimCC/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/SchemeDelimCC/demos/parsingTests.t b/SchemeDelimCC/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/SchemeDelimCC/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/SchemeDelimCC/dune b/SchemeDelimCC/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/SchemeDelimCC/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/SchemeDelimCC/dune-project b/SchemeDelimCC/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/SchemeDelimCC/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/SchemeDelimCC/lib/Pprintast.ml b/SchemeDelimCC/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/SchemeDelimCC/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/SchemeDelimCC/lib/Pprintast.mli b/SchemeDelimCC/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/SchemeDelimCC/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/SchemeDelimCC/lib/Printast.ml b/SchemeDelimCC/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/SchemeDelimCC/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/SchemeDelimCC/lib/Printast.mli b/SchemeDelimCC/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/SchemeDelimCC/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/SchemeDelimCC/lib/ast.mli b/SchemeDelimCC/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/SchemeDelimCC/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/SchemeDelimCC/lib/dune b/SchemeDelimCC/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/SchemeDelimCC/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/SchemeDelimCC/lib/interpret.ml b/SchemeDelimCC/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/SchemeDelimCC/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/SchemeDelimCC/lib/interpret.mli b/SchemeDelimCC/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/SchemeDelimCC/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/SchemeDelimCC/lib/lambda.ml b/SchemeDelimCC/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/SchemeDelimCC/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/SchemeDelimCC/lib/lambda.mli b/SchemeDelimCC/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/SchemeDelimCC/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/SchemeDelimCC/lib/parser.ml b/SchemeDelimCC/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/SchemeDelimCC/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/SchemeDelimCC/lib/parser.mli b/SchemeDelimCC/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/SchemeDelimCC/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/SchemeDelimCC/lib/tests.ml b/SchemeDelimCC/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/SchemeDelimCC/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/SchemeDelimCC/lib/utils.ml b/SchemeDelimCC/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/SchemeDelimCC/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/SchemeDelimCC/lib/utils.mli b/SchemeDelimCC/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/SchemeDelimCC/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/SchemeDelimCC/repl.t b/SchemeDelimCC/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/SchemeDelimCC/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/asm/asm.opam b/asm.opam similarity index 100% rename from asm/asm.opam rename to asm.opam diff --git a/asm/.gitignore b/asm/.gitignore deleted file mode 100644 index a0d98ef45..000000000 --- a/asm/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -*.annot -*.cmo -*.cma -*.cmi -*.a -*.o -*.cmx -*.cmxs -*.cmxa - -# ocamlbuild working directory -_build/ - -# ocamlbuild targets -*.byte -*.native - -# oasis generated files -setup.data -setup.log - -# Merlin configuring file for Vim and Emacs -.merlin - -# Dune generated files -*.install - -# Local OPAM switch -_opam/ - -_coverage \ No newline at end of file diff --git a/asm/COPYING b/asm/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/asm/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/asm/COPYING.CC0 b/asm/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/asm/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/asm/COPYING.LESSER b/asm/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/asm/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/asm/README.md b/asm/README.md deleted file mode 100644 index 7d5418bd3..000000000 --- a/asm/README.md +++ /dev/null @@ -1,13 +0,0 @@ -### An implementaion of NASM micro-language - -License: LGPL for implementation code + WTFPL for test examples in nasm-like language - -Author: Vadim Yakshigulov (vadim.iakshigulov@gmail.com) - -Features done: - -- parser -- ast -- interpreter - -Including SSE instructions and syscall diff --git a/asm/dune b/asm/dune deleted file mode 100644 index 3b1d7c9f9..000000000 --- a/asm/dune +++ /dev/null @@ -1,7 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) diff --git a/asm/bin/demoInterpreter.ml b/bin/demoInterpreter.ml similarity index 100% rename from asm/bin/demoInterpreter.ml rename to bin/demoInterpreter.ml diff --git a/asm/bin/demoInterpreter.t b/bin/demoInterpreter.t similarity index 100% rename from asm/bin/demoInterpreter.t rename to bin/demoInterpreter.t diff --git a/asm/bin/demoParser.ml b/bin/demoParser.ml similarity index 100% rename from asm/bin/demoParser.ml rename to bin/demoParser.ml diff --git a/asm/bin/demoParser.t b/bin/demoParser.t similarity index 100% rename from asm/bin/demoParser.t rename to bin/demoParser.t diff --git a/asm/bin/dune b/bin/dune similarity index 100% rename from asm/bin/dune rename to bin/dune diff --git a/asm/bin/sources/fib.asm b/bin/sources/fib.asm similarity index 100% rename from asm/bin/sources/fib.asm rename to bin/sources/fib.asm diff --git a/asm/bin/sources/matrix.asm b/bin/sources/matrix.asm similarity index 100% rename from asm/bin/sources/matrix.asm rename to bin/sources/matrix.asm diff --git a/asm/bin/sources/scalar.asm b/bin/sources/scalar.asm similarity index 100% rename from asm/bin/sources/scalar.asm rename to bin/sources/scalar.asm diff --git a/build_latest.sh b/build_latest.sh deleted file mode 100755 index 5f66c050c..000000000 --- a/build_latest.sh +++ /dev/null @@ -1,82 +0,0 @@ -#/bin/sh -x - -#set -ex - -if [ $# -eq 0 ] - then - echo "No arguments supplied" - exit 1 -fi - -STRAT= -if [ "$1" = "build" ]; then - STRAT="$1" -elif [ "$1" = "test" ]; then - STRAT="$1" -else - echo "bad argument $1" - exit 1 -fi - -rm -fr _opam -#export OPAMSWITCH=4.10.0 -eval $(opam env) -opam switch -which ocamlc -which ocaml - -echo -e "section_start:`date +%s`:Detecting project to build\r\e[0K run the tests" -LASTDIR=`./detect_latest.sh` - -if [ "$LASTDIR" = "." ]; then - git diff --name-only HEAD HEAD~1 - echo "DO NOTHING" -else - cd $LASTDIR - if test -f build.sbt; then - # Skipping CIing of Scala projects - exit 0 - fi - sh ../mylint.sh $LASTDIR - - eval $(opam env) - if [ "$STRAT" = "build" ]; then - #[ -d _opam ] || cp -r ~/.opam/4.10 _opam - #sudo apt install m4 -y - #opam update - opam install --deps-only -t -y . - if [ $? != 0 ]; then - echo "Installing dependencies failed" - exit 1 - fi - - echo -e "section_start:`date +%s`:Formatting...\r\e[0KFormatting..." - dune build @fmt - if [ $? = 0 ]; then - echo "Formatting OK" - else - echo "Formatting is not decent. Either intergrate ocamlformat to VsCode" - echo " or apply it manualy before every commit https://dune.readthedocs.io/en/stable/formatting.html" - exit 1 - fi - - echo -e "section_start:`date +%s`:Building...\r\e[0KBuilding..." - dune build - if [ $? = 0 ]; then - echo "Running $STRAT in $LASTDIR finished\n" - else - exit 1 - fi - else - echo -e "section_start:`date +%s`:Installing dependencies\r\e[0KInstalling dependencies..." - opam install --deps-only -t -y . - - echo -e "section_start:`date +%s`:Testing...\r\e[0K Testing..." - dune runtest - if [ $? = 0 ]; then - echo "Running $STRAT in $LASTDIR finished\n" - else - exit 1 - fi - fi -fi diff --git a/detect_latest.sh b/detect_latest.sh deleted file mode 100755 index 70e068e1e..000000000 --- a/detect_latest.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -git remote | grep upstream -if [ $? -ne 0 ] -then - git remote add upstream https://github.com/Kakadu/fp2023.git - git fetch upstream master -fi - -echo "" -CHANGES=`git diff-tree HEAD~1..HEAD | rev | cut -f 1 | rev` - -set answer="" -for dir in $CHANGES -do - #echo $dir - if [ -d "$dir" ]; then - if [ "$dir" != ".github" ]; then - answer="$answer $dir" - #echo dir answer="$answer" - fi - else - : - fi -done - -topnames=`echo $answer | xargs -n1 | sort -u | xargs` -rez=`echo $topnames | wc -l` -if [ "$rez" = "1" ]; then - echo "latest=$topnames" - exit 0 -else - echo "Too many cancdidates ($rez) to be a last solution" - echo "'$topnames'" - exit 1 -fi diff --git a/detect_latest_pr.ml b/detect_latest_pr.ml deleted file mode 100644 index 9ff0f3b21..000000000 --- a/detect_latest_pr.ml +++ /dev/null @@ -1,124 +0,0 @@ -#use "topfind";; - -#require "unix";; - -#require "str";; - -type config = - { mutable repo : string - ; mutable user : string - ; mutable user_branch : string - ; mutable verbose : bool - } - -let config = { user = "Kakadu"; repo = "fp2023"; user_branch = "master"; verbose = false } - -let () = - Arg.parse - [ "-repo", Arg.String (fun s -> config.repo <- s), " Github repository" - ; "-user", Arg.String (fun s -> config.user <- s), " Github user" - ; "-v", Arg.Unit (fun () -> config.verbose <- true), " verbose logging" - ] - (fun s -> config.user_branch <- s) - "TODO: help" -;; - -let red = "\027[0;31m" -let no_color = "\027[0m" -let log fmt = Format.kasprintf (fun s -> if config.verbose then print_endline s) fmt - -let get_output fmt = - Format.kasprintf - (fun cmd -> - log "Running: %s%s%s" red cmd no_color; - let ch = Unix.open_process_in cmd in - let s = In_channel.input_all ch in - let () = In_channel.close ch in - s) - fmt -;; - -let commandf fmt = Format.kasprintf Sys.command fmt - -open Printf - -(* let () = print_endline "hello world" *) - -let () = - let s = get_output "git remote | grep upstream" in - log "%S" s; - if not (List.mem "upstream" @@ Str.split (Str.regexp "\n") s) - then ( - let _ = - commandf - "git remote add upstream https://github.com/%s/%s.git" - config.user - config.repo - in - let _ = commandf "git fetch upstream master" in - Format.eprintf "Upstream added\n%!"; - ()) -;; - -let merge_base = - let s = get_output "git merge-base upstream/master %s" (* user_branch *) "HEAD" in - match Str.split (Str.regexp "\n") s |> List.filter (( <> ) "") with - | [ h ] -> h - | xs -> - Format.eprintf "After merge-base got a list of length %d\n%!" (List.length xs); - Format.eprintf "[ %s ]\n%!" (String.concat "; " xs); - exit 1 -;; - -let () = log "merge_base: %S" merge_base - -let calculate_common_subdir files = - let module SS = Set.Make (String) in - let get_top_dir name = - let prefix_len = - match String.index name '/' with - | exception Not_found -> String.length name - | n -> n - in - String.sub name 0 prefix_len - in - let set = List.fold_right (fun x acc -> SS.add (get_top_dir x) acc) files SS.empty in - SS.to_seq set |> List.of_seq -;; - -let pp_str_list ppf xs = Format.fprintf ppf "[ %s ]" (String.concat ", " xs) - -(* *) -let () = - let s = - get_output - "git diff-tree %s..%s | rev | cut -f 1 | rev" - merge_base - config.user_branch - in - log "%S " s; - let changed_files = - String.split_on_char '\n' s - |> List.filter (function - | "" -> false - | s - when Sys.file_exists s - && (not (Sys.is_directory s)) - && Filename.dirname s = Filename.current_dir_name -> false - | _ -> true) - in - log "%s " (String.concat ", " changed_files); - match changed_files with - | [] -> - Format.eprintf "No changed files.\n%!"; - exit 1 - | xs -> - (match calculate_common_subdir xs with - | [] -> assert false - | [ h ] -> - Format.printf "latest=%s\n" h; - exit 0 - | ds -> - Format.eprintf "Too many directories has been changed: %a\n%!" pp_str_list ds; - exit 1) -;; diff --git a/detect_latest_pr.sh b/detect_latest_pr.sh deleted file mode 100755 index 8e9372161..000000000 --- a/detect_latest_pr.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env sh - -git remote | grep upstream -if [ $? -ne 0 ] -then - git remote add upstream https://github.com/Kakadu/fp2023.git - git fetch upstream master -fi - -echo "" -CHANGES=`git diff-tree $(git merge-base upstream/master $1)..$1 | rev | cut -f 1 | rev` - -set answer="" -for dir in $CHANGES -do - #echo $dir - if [ -d "$dir" ]; then - if [ "$dir" != ".github" ]; then - answer="$answer\n$dir" - #echo dir answer="$answer" - fi - else - : - fi -done - -topnames=`echo $answer | sed '/^$/d' | uniq` -rez=`echo $topnames | wc -l` -if [ "$rez" = "1" ]; then - echo "latest=$topnames" - exit 0 -else - echo "Too many cancdidates ($rez) to be a last solution" - echo "'$topnames'" - exit 1 -fi diff --git a/asm/devbox.json b/devbox.json similarity index 100% rename from asm/devbox.json rename to devbox.json diff --git a/asm/devbox.lock b/devbox.lock similarity index 100% rename from asm/devbox.lock rename to devbox.lock diff --git a/CSharpExceptions/dune b/dune similarity index 100% rename from CSharpExceptions/dune rename to dune diff --git a/asm/dune-project b/dune-project similarity index 100% rename from asm/dune-project rename to dune-project diff --git a/exam.md b/exam.md deleted file mode 100644 index 532746790..000000000 --- a/exam.md +++ /dev/null @@ -1,51 +0,0 @@ -Темы (предварительные) к экзамену по ФП 2023-2024 - - -Вопросы-автоматы на оценку F обозначены ‡. - -1. Функции в программировании и функции в математике. Сходства и отличия. ‡ Понятие чистой функции -1. ‡ Алгебраические типы данных. Что такое и в чем их алгебраичность? - * Boolean blindness -1. ‡ Хвостовая рекурсия. Уметь объяснять, чем хвостовая лучше обычной обычной рекурсии примерах. CPS - * Переход к хвостовой рекурсии. (переписать функцию, что дал экзаменатор) -1. Continuation passing style. Преобразование функций из стандартного (direct) стиля в CPS - * ‡ Быть готовыми переписать функцию в CPS (функция выбирается экзаменатором) -1. Лямбда-исчисление - * ‡ Привести (подготовить заранее) трассу вычисления факториала (или фибоначчи) для каждой из стратегий - (CBN, CBV, NO, AO) для "голого" лямбда исчисления. (Функцию и стратегию выбирает экзаменатор.) - Демонстрировать понимание того, как проходят редукции в указанной стратегии - * Понятие исчисления. Аксиомы, правила вывода, посылки и заключения. Доказательства - * ‡ Определение языка лямбда-выражений. Три правила (α, β, η) преобразования лямбда-выражений. - * Лямбда исчисление как универсальный язык программирования. Числа Чёрча, арифметика, ветвления - * Редексы. Стратегии вычисления лямбда-термов: CBN, CBV, CBNeeded, NO, AO. Достоинства и недостатки - * Написание рекурсивных функций без использования рекурсии. Комбинаторы неподвижной точки для разных стратегий. Примеры - * Capture avoiding substitution. Индексы и уровни де Брёйна -1. ‡ Определение монады. Стандартные монады: Maybe/Option, Result, List, Identity, Parser, Concurrency. - * Как в использовании отличаются монады и исключения? -1. Аппликативные функторы. Чем отличаются от монад, и когда их стоит предпочитать монадам? -1. Парсер-комбинаторы. - * ‡ Пример: синтаксический анализатор языка a^n b^n c^n (где а,b,c -- символы алфавита, ^n -- n вхождений подряд). - Плохой вход должен детектироваться максимально рано. -1. Унификация и подстановки. Occurs check. - * Уметь демонстрировать преимущества и недостатки включения/выключения occurs check. - * ‡ Уметь проунифицировать на примере экзаменатора. -1. ‡ STLC. Понятие схемы типов. -1. Вывод типов в системе Хиндли-Милнера. Правила, которые отличают от STLC. -1. ‡ Понятие мемоизации - * Пример: эффективное вычисление чисел Фибоначчи -1. Ленивые списки (потоки) - * Стандартные задачи: фибоначчи -1. PFDS. ‡ Понятие неизменяемых и устойчивых (persistent) типов данных. -1. PFDS. Чисто функциональные очереди. Три реализации и их асимптотики. -1. PFDS. Понятие префиксных деревьев и HAMT. -1. Схемы рекурсии. На примере списков и деревьев. Ката- и анаморфизмы. -1. Схемы рекурсии. Хиломорфизм. Решения задач: фибоначчи, binary partition, LCS, merge sort. - * ‡ Идея реализации динамического программирования через схемы рекурсии - - diff --git a/find_clones.py b/find_clones.py deleted file mode 100755 index aa8837b20..000000000 --- a/find_clones.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -import sys -import os - -LANG=sys.argv[1] - -REPORTS_DIR="_reports" -REPORT_FILE="jscpd_report.txt" -def good_dir(d): - return os.path.isdir(os.path.join(".", d)) and not d.startswith('.') and d != LANG and d != REPORTS_DIR - -if not os.path.exists("_reports"): - os.mkdir("_reports") -os.system("find . -iname _build -exec rm -fr {} \;") - -NPM_BIN='/home/user/.local/bin' -for x in [x for x in os.listdir(".") if good_dir(x)]: - cmd = f"{NPM_BIN}/jscpd --pattern '{LANG}/**/*.ml*' --pattern '{x}/**/*.ml*' -b -r consoleFull --skipLocal > _reports/vs_{x}.txt" - print(cmd) - os.system(cmd) - -if 1: - print("Looking for clones in itself"); - cmd = f"{NPM_BIN}/jscpd --pattern '{LANG}/**/*.ml*' -b -r consoleFull > _reports/vs_{LANG}.txt" - os.system(cmd) - -os.system(f"cat {REPORTS_DIR}/*.txt > {REPORT_FILE}") diff --git a/asm/lib/ast/ast.ml b/lib/ast/ast.ml similarity index 100% rename from asm/lib/ast/ast.ml rename to lib/ast/ast.ml diff --git a/asm/lib/ast/dune b/lib/ast/dune similarity index 100% rename from asm/lib/ast/dune rename to lib/ast/dune diff --git a/asm/lib/interpreter/containers.ml b/lib/interpreter/containers.ml similarity index 100% rename from asm/lib/interpreter/containers.ml rename to lib/interpreter/containers.ml diff --git a/asm/lib/interpreter/containers.mli b/lib/interpreter/containers.mli similarity index 100% rename from asm/lib/interpreter/containers.mli rename to lib/interpreter/containers.mli diff --git a/asm/lib/interpreter/dune b/lib/interpreter/dune similarity index 100% rename from asm/lib/interpreter/dune rename to lib/interpreter/dune diff --git a/asm/lib/interpreter/interpreter.ml b/lib/interpreter/interpreter.ml similarity index 100% rename from asm/lib/interpreter/interpreter.ml rename to lib/interpreter/interpreter.ml diff --git a/asm/lib/interpreter/interpreter.mli b/lib/interpreter/interpreter.mli similarity index 100% rename from asm/lib/interpreter/interpreter.mli rename to lib/interpreter/interpreter.mli diff --git a/asm/lib/interpreter/state.ml b/lib/interpreter/state.ml similarity index 100% rename from asm/lib/interpreter/state.ml rename to lib/interpreter/state.ml diff --git a/asm/lib/interpreter/state.mli b/lib/interpreter/state.mli similarity index 100% rename from asm/lib/interpreter/state.mli rename to lib/interpreter/state.mli diff --git a/asm/lib/parser/common.ml b/lib/parser/common.ml similarity index 100% rename from asm/lib/parser/common.ml rename to lib/parser/common.ml diff --git a/asm/lib/parser/common.mli b/lib/parser/common.mli similarity index 100% rename from asm/lib/parser/common.mli rename to lib/parser/common.mli diff --git a/asm/lib/parser/directive.ml b/lib/parser/directive.ml similarity index 100% rename from asm/lib/parser/directive.ml rename to lib/parser/directive.ml diff --git a/asm/lib/parser/directive.mli b/lib/parser/directive.mli similarity index 100% rename from asm/lib/parser/directive.mli rename to lib/parser/directive.mli diff --git a/asm/lib/parser/dune b/lib/parser/dune similarity index 100% rename from asm/lib/parser/dune rename to lib/parser/dune diff --git a/asm/lib/parser/immediate.ml b/lib/parser/immediate.ml similarity index 100% rename from asm/lib/parser/immediate.ml rename to lib/parser/immediate.ml diff --git a/asm/lib/parser/immediate.mli b/lib/parser/immediate.mli similarity index 100% rename from asm/lib/parser/immediate.mli rename to lib/parser/immediate.mli diff --git a/asm/lib/parser/operand.ml b/lib/parser/operand.ml similarity index 100% rename from asm/lib/parser/operand.ml rename to lib/parser/operand.ml diff --git a/asm/lib/parser/operand.mli b/lib/parser/operand.mli similarity index 100% rename from asm/lib/parser/operand.mli rename to lib/parser/operand.mli diff --git a/asm/lib/parser/parser.ml b/lib/parser/parser.ml similarity index 100% rename from asm/lib/parser/parser.ml rename to lib/parser/parser.ml diff --git a/asm/lib/parser/parser.mli b/lib/parser/parser.mli similarity index 100% rename from asm/lib/parser/parser.mli rename to lib/parser/parser.mli diff --git a/asm/lib/parser/register.ml b/lib/parser/register.ml similarity index 100% rename from asm/lib/parser/register.ml rename to lib/parser/register.ml diff --git a/asm/lib/parser/register.mli b/lib/parser/register.mli similarity index 100% rename from asm/lib/parser/register.mli rename to lib/parser/register.mli diff --git a/asm/lib/parser/statement.ml b/lib/parser/statement.ml similarity index 100% rename from asm/lib/parser/statement.ml rename to lib/parser/statement.ml diff --git a/asm/lib/parser/statement.mli b/lib/parser/statement.mli similarity index 100% rename from asm/lib/parser/statement.mli rename to lib/parser/statement.mli diff --git a/lint_filesystem.py b/lint_filesystem.py deleted file mode 100755 index e3e523fb1..000000000 --- a/lint_filesystem.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -import sys -import os.path -import subprocess - -LASTDIR=sys.argv[1] - -#print("Current working directory: {0}\n".format(os.getcwd())) - -print("Going to run tests in $PWD...") -PKG_OPAM=f"./{LASTDIR}.opam" -if not os.path.isfile(f"{PKG_OPAM}"): - print(f"File {PKG_OPAM} does not exist. Exit\n") - exit(1) - -errors_found=False - -# A few warnings were disabled -# 21: Field 'opam-version' doesn't match the current version -subpr = subprocess.Popen(["opam", "lint", "-s", "--warnings=-21-23", f"{PKG_OPAM}"], stdout=subprocess.PIPE) -if subpr.wait() != 0: - print("Linting failed") - subpr_rez = subpr.stdout.read().decode('utf-8') - print(subpr_rez) - exit(1) - -def check_spec(field): - pr = subprocess.Popen(["opam", "show", PKG_OPAM, "--field", field], stdout=subprocess.PIPE) - if pr.wait() != 0: - sys.stderr.write(f"Can't read field {field}\n") - errors_found = True - else: - rez = pr.stdout.read().decode('utf-8').rstrip() - if rez.find("FIXME") != -1: - sys.stderr.write(f"Wrong value of the field '{field}': {rez}\n") - if LASTDIR != "Lambda": - errors_found = True - else: - print(f"decent value {rez}") - -check_spec("synopsis") -check_spec("description") -check_spec("authors") -check_spec("maintainer") - -if errors_found: - exit(1) -else: - exit(0) diff --git a/mini-SQL/.gitignore b/mini-SQL/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/mini-SQL/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/mini-SQL/.ocamlformat b/mini-SQL/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/mini-SQL/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/mini-SQL/COPYING b/mini-SQL/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/mini-SQL/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/mini-SQL/COPYING.CC0 b/mini-SQL/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/mini-SQL/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/mini-SQL/COPYING.LESSER b/mini-SQL/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/mini-SQL/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/mini-SQL/Makefile b/mini-SQL/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/mini-SQL/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/mini-SQL/README.md b/mini-SQL/README.md deleted file mode 100644 index 2c4e2c0a4..000000000 --- a/mini-SQL/README.md +++ /dev/null @@ -1 +0,0 @@ -### :( diff --git a/mini-SQL/REPL.ml b/mini-SQL/REPL.ml deleted file mode 100644 index 0848fee0f..000000000 --- a/mini-SQL/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -(* open Base *) -(* open Lib *) -(* *) -(* let run_repl _ = *) -(* Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" *) -(* ;; *) -(* *) -(* let run_single eval = *) -(* let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in *) -(* let ast = Parser.parse text in *) -(* match ast with *) -(* | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e *) -(* | Result.Ok ast -> *) -(* Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; *) -(* (match eval ast with *) -(* | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) *) -(* ;; *) -(* *) -(* type strategy = *) -(* | CBN *) -(* | CBV *) -(* | NO *) -(* | AO *) -(* *) -(* type opts = *) -(* { mutable batch : bool *) -(* ; mutable stra : strategy *) -(* } *) -(* *) -(* let () = *) -(* let opts = { batch = false; stra = CBN } in *) -(* let open Stdlib.Arg in *) -(* parse *) -(* [ ( "-" *) -(* , Unit (fun () -> opts.batch <- true) *) -(* , "Read from stdin single program, instead of running full REPL" ) *) -(* ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" *) -(* ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" *) -(* ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" *) -(* ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" *) -(* ] *) -(* (fun _ -> *) -(* Stdlib.Format.eprintf "Positioned arguments are not supported\n"; *) -(* Stdlib.exit 1) *) -(* "Read-Eval-Print-Loop for Utyped Lambda Calculus"; *) -(* let eval = *) -(* Lambda.apply_strat *) -(* (match opts.stra with *) -(* | NO -> Lambda.nor_strat *) -(* | CBV -> Lambda.cbv_strat *) -(* | AO -> Lambda.ao_strat *) -(* | CBN -> Lambda.cbn_strat) *) -(* in *) -(* (if opts.batch then run_single else run_repl) eval *) -(* ;; *) -(* *) diff --git a/mini-SQL/demos/demoAO.ml b/mini-SQL/demos/demoAO.ml deleted file mode 100644 index 3a2dc6cd6..000000000 --- a/mini-SQL/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -(* open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; *) - -(* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - -(* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in -*) -(* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -(* end *) diff --git a/mini-SQL/demos/demoNO.ml b/mini-SQL/demos/demoNO.ml deleted file mode 100644 index feaddab08..000000000 --- a/mini-SQL/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) -(* - open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) *) -(* let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) *) -(* let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) *) -(* let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) *) -(* ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) *) -(* ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end *) diff --git a/mini-SQL/demos/demoParse.ml b/mini-SQL/demos/demoParse.ml deleted file mode 100644 index d4ba684a4..000000000 --- a/mini-SQL/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -let parse inp = Angstrom.parse_string ~consume:All Lib.Parser.statement_parser inp - -let () = - let inp = Stdio.In_channel.input_all Caml.stdin in - match parse inp with - | Result.Ok x -> Format.printf "Parse result: %s" (Lib.Ast.show_command x) - | Error e -> Format.printf "Error%s" e -;; diff --git a/mini-SQL/demos/demo_input.txt b/mini-SQL/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/mini-SQL/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/mini-SQL/demos/dune b/mini-SQL/demos/dune deleted file mode 100644 index 8122f6926..000000000 --- a/mini-SQL/demos/dune +++ /dev/null @@ -1,36 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries Lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries Lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries Lib stdio) - (instrumentation - (backend bisect_ppx))) - -; (cram -; (applies_to interpretTests) -; (deps -; ./demoNO.exe -; ./demoAO.exe -; ./demoParse.exe -; ../REPL.exe -; ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps ./demoParse.exe)) diff --git a/mini-SQL/demos/parsingTests.t b/mini-SQL/demos/parsingTests.t deleted file mode 100644 index 2c5531c2c..000000000 --- a/mini-SQL/demos/parsingTests.t +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > SELECT * FROM table WHERE True - Parse result: Select {exprs = [All_Columns]; table = "table"; - condition = (Some (Const (Bool true)))} - - $ ./demoParse.exe <<-EOF - > SELECT *, *, Name, age, 1 + 1 FROM table WHERE NOT False - Parse result: Select { - exprs = - [All_Columns; All_Columns; (Expr (Const (Name "Name"))); - (Expr (Const (Name "age"))); - (Expr (Binary_operation (Add, (Const (Digit 1)), (Const (Digit 1)))))]; - table = "table"; - condition = (Some (Unary_operation (Not, (Const (Bool false)))))} diff --git a/mini-SQL/dune b/mini-SQL/dune deleted file mode 100644 index d8ee4ea44..000000000 --- a/mini-SQL/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/mini-SQL/dune-project b/mini-SQL/dune-project deleted file mode 100644 index 33f20ccae..000000000 --- a/mini-SQL/dune-project +++ /dev/null @@ -1,32 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "Zaytsev Dmitriy") - -(maintainers "Zaytsev Dmitriy") - -(bug_reports "https://github.com/d-zaytsev/fp2023") - -(homepage "https://github.com/d-zaytsev/fp2023") - -(package - (name mini-SQL) - (synopsis "An interpreter for SQL") - (description - "Mini-SQL interpreter. Language includes keywords: SELECT, JOIN, WHERE.") - (version 1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - ppx_variants_conv - (odoc :with-doc) - (ocamlformat :build))) diff --git a/mini-SQL/lib/ast.ml b/mini-SQL/lib/ast.ml deleted file mode 100644 index 1824592d9..000000000 --- a/mini-SQL/lib/ast.ml +++ /dev/null @@ -1,46 +0,0 @@ -type value = - | Name of string - | String of string - | Digit of int - | Bool of bool -[@@deriving show { with_path = false }] - -type unary_op = Not [@@deriving show { with_path = false }] - -type bin_op = - (* Arithmetic *) - | Add - | Substract - | Multiply - | Divide - | Modulo - (* Logic *) - | And - | Or - (* Compare *) - | Equal - | NotEqual - | GreaterThan - | LessThan - | LessThanOrEqual - | GreaterThanOrEqual -[@@deriving show { with_path = false }] - -type expr = - | Const of value - | Unary_operation of unary_op * expr - | Binary_operation of bin_op * expr * expr -[@@deriving show { with_path = false }] - -type select_expr = - | All_Columns - | Expr of expr -[@@deriving show { with_path = false }] - -type command = - | Select of - { exprs : select_expr list - ; table : string - ; condition : expr option - } -[@@deriving show { with_path = false }] diff --git a/mini-SQL/lib/dune b/mini-SQL/lib/dune deleted file mode 100644 index b565cf485..000000000 --- a/mini-SQL/lib/dune +++ /dev/null @@ -1,8 +0,0 @@ -(library - (name Lib) - (inline_tests) - (preprocess - (pps ppx_inline_test ppx_deriving.show ppx_deriving.ord ppx_variants_conv)) - (libraries angstrom) - (instrumentation - (backend bisect_ppx))) diff --git a/mini-SQL/lib/parser.ml b/mini-SQL/lib/parser.ml deleted file mode 100644 index 909d67ab9..000000000 --- a/mini-SQL/lib/parser.ml +++ /dev/null @@ -1,217 +0,0 @@ -open Angstrom -open Ast - -exception Parse_error of string - -(* IS *) -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let is_digit = function - | '0' .. '9' -> true - | _ -> false -;; - -let is_letter = function - | 'a' .. 'z' | 'A' .. 'Z' | '_' -> true - | _ -> false -;; - -(* Correct name for column or table.contents - - Names can contain letters of the Latin alphabet (upper or lower case), numbers and underscores ('_')*) -let is_naming_letter c = is_letter c || is_digit c - -let is_string_s_char = function - | '\'' | '\"' -> true - | _ -> false -;; - -let is_arithm_op = function - | '+' | '-' | '/' | '*' | '%' -> true - | _ -> false -;; - -let is_condition_op = function - | '>' | '<' | '=' | '!' -> true - | _ -> false -;; - -(* Digit parser *) - -let digit_parser = - lift2 - (fun s d -> - match s with - | x when x = '+' -> Digit (int_of_string d) - | x when x = '-' -> Digit (-1 * int_of_string d) - | _ -> raise (Parse_error "Can't parse digit")) - (peek_char - >>= function - | Some x when x = '+' -> advance 1 *> return '+' - | Some x when is_digit x -> return '+' - | Some x when x = '-' -> advance 1 *> return '-' - | _ -> fail "Can't parse digit") - (take_while is_digit) -;; - -(* String parser *) -let string_parser = - advance 1 *> take_while (fun c -> not (is_string_s_char c)) - >>= fun s -> return (String s) <* advance 1 -;; - -(* Parser for column/table names*) - -let name_parser_s = - (peek_char - >>= function - | Some x when is_letter x -> return (String.make 1 x) - | _ -> fail "Names must begin with a letter of the Latin alphabet") - *> take_while is_naming_letter - >>= fun str -> return str -;; - -let name_parser = name_parser_s >>| fun r -> Name r - -(** Bool value parser *) -let bool_parser = - string_ci "true" - <|> string_ci "false" - >>= fun r -> - match String.lowercase_ascii r with - | "true" -> return (Bool true) - | "false" -> return (Bool false) - | _ -> fail "Can't parse bool" -;; - -(* Space parsers *) -let space_skip = skip_while is_space -let space_left p = space_skip *> p -let space_right p = p <* space_skip -let space_both p = space_skip *> p <* space_skip - -(** Const of value parser *) -let value = digit_parser <|> bool_parser <|> name_parser <|> string_parser - -(* --- BINARY OPERATORS ---*) - -(** Arithm operators parser*) -let arithm_op_parser = - satisfy is_arithm_op - >>= fun op -> - match op with - | '+' -> return Add - | '-' -> return Substract - | '/' -> return Divide - | '*' -> return Multiply - | '%' -> return Modulo - | _ -> fail "Unsupported arithmetic operator" -;; - -(** Logic operators parser *) -let logic_op_parser = - take_while (fun c -> not (is_space c)) - >>= fun op -> - match op with - | "AND" -> return And - | "OR" -> return Or - | _ -> fail "Can't parse binary logic operator" -;; - -(** Compare operators parser *) -let compare_op_parser = - let str_p = - satisfy is_condition_op - >>= fun c1 -> - peek_char - >>= fun cx -> - match cx with - | Some c2 when not (is_condition_op c2) -> return (String.make 1 c1) - | Some c2 -> advance 1 *> return (String.make 1 c1 ^ String.make 1 c2) - | None -> fail "Unsupported compare operator" - in - lift - (function - | "=" -> Equal - | "<>" | "!=" -> NotEqual - | ">" -> GreaterThan - | "<" -> LessThan - | ">=" -> GreaterThanOrEqual - | "<=" -> LessThanOrEqual - | _ -> raise (Parse_error "Unsupported compare operator")) - str_p -;; - -(** Binary operators parser *) -let bin_op_parser = logic_op_parser <|> compare_op_parser <|> arithm_op_parser - -(* --- Unary operators --- *) - -(** NOT parser *) -let unary_logic_parser = - take_while (fun c -> not (is_space c)) - >>= fun r -> - match r with - | "NOT" -> return Not - | _ -> fail "Can't parse logic operator" -;; - -(** Unary operators parser*) - -let un_op_parser = unary_logic_parser -let expr_parser = - let const = value >>| fun r -> Const r in - lift2 (* | Unary operation *) - (fun op x -> Unary_operation (op, x)) - (space_right un_op_parser) - const - <|> lift3 (* | Binary operation *) - (fun l op r -> Binary_operation (op, l, r)) - const - (space_both bin_op_parser) - const - <|> const -;; -(** exprs parser *) - - - -(** SELECT parser *) - -let select_expr_parser = - let choice_pars = - choice - [ (* "*" Parse *) - (space_both peek_char - >>= fun c -> - match c with - | Some x when x = '*' -> advance 1 *> return All_Columns - | Some _ | None -> fail "Can't parse All Columns") - ; (* Other exprs pars*) - (expr_parser >>| fun r -> Expr r) - ] - in - sep_by1 (space_both (char ',')) choice_pars -;; - -(* Statements parser*) - -let statement_parser = - let sfw_pars = - space_both (string "SELECT") *> select_expr_parser - >>= fun exprs -> - space_both (string "FROM") *> name_parser_s - >>= fun name -> - space_both (string "WHERE") *> space_right expr_parser - >>= fun expr -> return (Select { exprs; table = name; condition = Some expr }) - in - let sf_pars = - space_both (string "SELECT") *> select_expr_parser - >>= fun exprs -> - space_both (string "FROM") *> space_right name_parser_s - >>= fun name -> return (Select { exprs; table = name; condition = None }) - in - choice [ sfw_pars; sf_pars ] -;; diff --git a/mini-SQL/lib/test.ml b/mini-SQL/lib/test.ml deleted file mode 100644 index 94d0cbc5d..000000000 --- a/mini-SQL/lib/test.ml +++ /dev/null @@ -1,81 +0,0 @@ -open Parser -open Ast - -(* Запускает парсер на строке *) -let run p = Angstrom.parse_string ~consume:All p - -let assert_equal parser input expected = - match run parser input with - | Ok res when res = expected -> true - | _ -> false -;; - -let assert_eq_output f parser input expected = - let res = run parser input in - match res with - | Ok res when res <> expected -> - Format.printf "Parsing result: %s!!!\n" (f res); - false - | Ok _ -> true - | Error x -> Format.printf "Parsing error: %s!!!\n" x; false -;; - -let assert_raise parser input = - let tryRun p i = - match run p i with - | Ok _ -> true - | _ -> false - in - try not (tryRun parser input) with - | _ -> true -;; - -let%test _ = assert_equal value "\'1a2b3c 7\'" (String "1a2b3c 7") -let%test _ = assert_equal value "\"1a2b3c 7\"" (String "1a2b3c 7") -let%test _ = assert_equal value "User" (Name "User") -let%test _ = assert_equal value "True" (Bool true) -let%test _ = assert_equal value "false" (Bool false) -let%test _ = assert_equal value "10" (Digit 10) -let%test _ = assert_equal value "+10" (Digit 10) -let%test _ = assert_equal value "-10" (Digit (-10)) -(**) -let%test _ = assert_raise value "-12a3" -let%test _ = assert_raise value "1name" - -(*Expr parser*) -let%test _ = assert_equal expr_parser "NOT 1" (Unary_operation(Not, Const (Digit 1))) -let%test _ = assert_equal expr_parser "2+2" (Binary_operation (Add, Const (Digit 2), Const (Digit 2))) -let%test _ = assert_eq_output show_expr expr_parser "2 + 2" (Binary_operation (Add, Const (Digit 2), Const (Digit 2))) -let%test _ = assert_equal expr_parser "2 / -2" (Binary_operation (Divide, Const (Digit 2), Const (Digit (-2)))) -let%test _ = assert_equal expr_parser "-2 - -2" (Binary_operation (Substract, Const (Digit (-2)), Const (Digit (-2)))) -let%test _ = assert_equal expr_parser "-2 * +2" (Binary_operation (Multiply, Const (Digit (-2)), Const (Digit 2))) -let%test _ = assert_equal expr_parser "123 % 10" (Binary_operation (Modulo, Const (Digit 123), Const (Digit 10))) - -let%test _ = assert_raise expr_parser "-2 x 2" - -let%test _ = assert_eq_output show_expr expr_parser "4=4" (Binary_operation (Equal, Const (Digit 4), Const (Digit 4))) -let%test _ = assert_equal expr_parser "10 >4" (Binary_operation (GreaterThan, Const (Digit 10), Const (Digit 4))) -let%test _ = assert_equal expr_parser "2 < 4" (Binary_operation (LessThan, Const (Digit 2), Const (Digit 4))) -let%test _ = assert_equal expr_parser "2 != 4" (Binary_operation (NotEqual, Const (Digit 2), Const (Digit 4))) -let%test _ = assert_equal expr_parser "5<> 4" (Binary_operation (NotEqual, Const (Digit 5), Const (Digit 4))) -let%test _ = assert_equal expr_parser "4 <= 4" (Binary_operation (LessThanOrEqual, Const (Digit 4), Const (Digit 4))) -let%test _ = assert_equal expr_parser "7>=4" (Binary_operation (GreaterThanOrEqual, Const (Digit 7), Const (Digit 4))) -(**) -let%test _ = assert_raise expr_parser "2 + 2 eq 4" -let%test _ = assert_equal expr_parser "ID>= 0" (Binary_operation (GreaterThanOrEqual, Const (Name "ID"), Const (Digit 0))) - -(* Logic expr parser *) - -let%test _ = assert_equal expr_parser "True AND age" (Binary_operation (And, Const (Bool true), Const (Name "age"))) -let%test _ = assert_equal expr_parser "False OR True" (Binary_operation (Or, Const (Bool false), Const (Bool true))) -let%test _ = assert_equal expr_parser "NOT true" (Unary_operation (Not, Const (Bool true))) - -(* SELECT exprs pars*) - -let%test _ = assert_equal select_expr_parser "*" [All_Columns] -let%test _ = assert_equal select_expr_parser "*, ID" [All_Columns; Expr (Const ( Name "ID"))] - -(* SELECT - FROM - WHERE*) - -let%test _ = assert_equal statement_parser "SELECT ID, name FROM User" (Select {exprs = [Expr (Const ( Name "ID")); Expr (Const ( Name "name"))]; table = "User"; condition = None}) -let%test _ = assert_equal statement_parser "SELECT * FROM User WHERE age >25" (Select {exprs = [All_Columns]; table = "User"; condition = Some (Binary_operation (GreaterThan, Const (Name "age"), Const (Digit 25)))}) \ No newline at end of file diff --git a/mini-SQL/mini-SQL.opam b/mini-SQL/mini-SQL.opam deleted file mode 100644 index ba03bd7e9..000000000 --- a/mini-SQL/mini-SQL.opam +++ /dev/null @@ -1,36 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "1" -synopsis: "An interpreter for SQL" -description: - "Mini-SQL interpreter. Language includes keywords: SELECT, JOIN, WHERE." -maintainer: ["Zaytsev Dmitriy"] -authors: ["Zaytsev Dmitriy"] -license: "LGPL-3.0-or-later" -homepage: "https://github.com/d-zaytsev/fp2023" -bug-reports: "https://github.com/d-zaytsev/fp2023" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "ppx_variants_conv" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/named and optional arguments/.gitignore b/named and optional arguments/.gitignore deleted file mode 100644 index 7102a822c..000000000 --- a/named and optional arguments/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -_build -_coverage -/_esy -/node_modules -/esy.lock -/.melange.eobjs diff --git a/named and optional arguments/.ocamlformat b/named and optional arguments/.ocamlformat deleted file mode 100644 index a71382926..000000000 --- a/named and optional arguments/.ocamlformat +++ /dev/null @@ -1,4 +0,0 @@ -profile=janestreet -sequence-style=terminator -max-indent=2 - diff --git a/named and optional arguments/COPYING b/named and optional arguments/COPYING deleted file mode 100644 index f288702d2..000000000 --- a/named and optional arguments/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "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. - - 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. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - 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. - - 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. - - 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. - - 1. Source Code. - - 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. - - 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. - - 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. - - 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. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - 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. - - 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. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - 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. - - 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. - - 4. Conveying Verbatim Copies. - - 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. - - 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. - - 5. Conveying Modified Source Versions. - - 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: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - 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". - - 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. - - 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. - - 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. - - 6. Conveying Non-Source Forms. - - 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: - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - "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. - - 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). - - 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. - - 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. - - 7. Additional Terms. - - "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. - - 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. - - 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: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - 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 - - 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 - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - 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. - - 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. - - 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. - - 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. - - 8. Termination. - - 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). - - 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. - - 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. - - 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. - - 9. Acceptance Not Required for Having Copies. - - 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. - - 10. Automatic Licensing of Downstream Recipients. - - 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. - - 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. - - 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. - - 11. Patents. - - 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". - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 12. No Surrender of Others' Freedom. - - 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. - - 13. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU 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 General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU 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. - - 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. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - 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. - - 17. Interpretation of Sections 15 and 16. - - 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. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/named and optional arguments/COPYING.CC0 b/named and optional arguments/COPYING.CC0 deleted file mode 100644 index 0e259d42c..000000000 --- a/named and optional arguments/COPYING.CC0 +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/named and optional arguments/COPYING.LESSER b/named and optional arguments/COPYING.LESSER deleted file mode 100644 index 0a041280b..000000000 --- a/named and optional arguments/COPYING.LESSER +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser 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. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/named and optional arguments/DONT_REMOVE_THIS_DIRECTORY.md b/named and optional arguments/DONT_REMOVE_THIS_DIRECTORY.md deleted file mode 100644 index e0530079f..000000000 --- a/named and optional arguments/DONT_REMOVE_THIS_DIRECTORY.md +++ /dev/null @@ -1,3 +0,0 @@ -This file should be contained in template directoty `Lambda`. -You should remove it when you copy `Lambda` for your -personal pet project. diff --git a/named and optional arguments/Lambda.opam b/named and optional arguments/Lambda.opam deleted file mode 100644 index 1bd9c9da0..000000000 --- a/named and optional arguments/Lambda.opam +++ /dev/null @@ -1,35 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -version: "0.1" -synopsis: "FIXME An interpreter for language" -description: - "FIXME. A longer description, for example, which are the most interesing features being supported, etc." -maintainer: ["FIXME Vasya Pupkin"] -authors: ["FIXME Vasya Pupkin"] -license: "LGPL-3.0-or-later" -homepage: "FIXME Homepage" -bug-reports: "FIXME where to put bug reports about the code" -depends: [ - "dune" {>= "3.7"} - "angstrom" - "ppx_inline_test" {with-test} - "ppx_expect" - "ppx_deriving" - "bisect_ppx" - "odoc" {with-doc} - "ocamlformat" {build} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] diff --git a/named and optional arguments/Makefile b/named and optional arguments/Makefile deleted file mode 100644 index 1b1e250a3..000000000 --- a/named and optional arguments/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -.PHONY: repl tests test fmt lint celan - -all: - dune build - -repl: - dune build ./REPL.exe && rlwrap _build/default/REPL.exe - -tests: test -test: - dune runtest - -celan: clean -clean: - @$(RM) -r _build - -fmt: - dune build @fmt --auto-promote - -lint: - dune build @lint --force - -release: - dune build --profile=release - dune runtest --profile=release - -TEST_COV_D = /tmp/cov -COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect demos/ - -.PHONY: test_coverage coverage -test_coverage: coverage -coverage: - $(RM) -r $(TEST_COV_D) - mkdir -p $(TEST_COV_D) - BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \ - --instrument-with bisect_ppx --force - bisect-ppx-report html $(COVERAGE_OPTS) - bisect-ppx-report summary $(COVERAGE_OPTS) - @echo "Use 'xdg-open _coverage/index.html' to see coverage report" diff --git a/named and optional arguments/README.md b/named and optional arguments/README.md deleted file mode 100644 index 6bcd8739d..000000000 --- a/named and optional arguments/README.md +++ /dev/null @@ -1,97 +0,0 @@ -### An implementaion of Lambda mini-language - -This is a homework for functional programming course. - -License: LGPL for implementation code + WTFPL for test examles in miniLanguage - -Author: Vasy Pupkin, vasya@pupkin.com - -Features done (append only): - -- Parser (for example) -- interpreter of non-recursive functions (for example) -- ... - -Features in progress (and TODOs): - -- Interpreter of recursive functions is not yet ready (for example) -- TODO: make pretty-printing less memory consuming (for example) -- ... - - -##### Замечания по стилю кодирования - -- Если merge request не проходит CI -- проверяться не будет -- Замечания должны быть откомментированы, иначе проверяться не будет. - - Если исправлены, должны быть поменчены как "исправлены" - - Если непонятны/некорректны, то это должно быть откомментировано соответствующим образом. - - Такие суровые ограничения вводятся, чтобы замечания не игнорировались. - -- Иимена типов и функций -- snake_case -- Имена типов модулей и модулей -- CamelCase -- Ворнинги должны быть пофикшены -- Не стесняйтесь писать `if ... then ... else` вместо `match ... with true -> .. | false -> ...` -- Не стесняйтесь писать гварды в мэтчинге, например -```ocaml -match ... with -| x when f x -> ... -| x -> ... -| ... -``` -вместо -```ocaml -match ... with -| x -> if f x then ... else ... -| ... -``` -- Вместо `fun x y -> match y with` лучше писать короче: `fun x -> function` -- Используйте quoted string literals в тестах, чтобы не экранировать руками -``` -─( 11:21:01 )─< command 1 >──────────────────────────── -utop # {| - int main () { - return 0; - } - |};; -- : string = "\n int main () {\n return 0;\n }\n " -``` -- Не надо писать -```ocaml -match ... with -| x -> - Hashtbl.replace tbl key value |> fun () -> ... -``` -Лучше -```ocaml -match ... with -| x -> - let () = Hashtbl.replace tbl key value in - ... -``` -или -```ocaml -match ... with -| x -> ( - Hashtbl.replace tbl key value; - ... - ) -``` -или даже -```ocaml -match ... with -| x -> begin - Hashtbl.replace tbl key value; - ... - end -``` -- Не надо писать -```ocaml -let x = if long_expression then true else false in ... -``` -лучше -```ocaml -let x = long_expression in ... -``` - -- 1 diff --git a/named and optional arguments/REPL.ml b/named and optional arguments/REPL.ml deleted file mode 100644 index a88cdd31e..000000000 --- a/named and optional arguments/REPL.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Base -open Lambda_lib - -let run_repl _ = - Stdlib.Format.eprintf "OCaml-style toplevel (ocamlc, utop) is not implemented" -;; - -let run_single eval = - let open Lambda_lib in - let text = Stdio.In_channel.(input_all stdin) |> String.rstrip in - let ast = Parser.parse text in - match ast with - | Error e -> Stdlib.Format.printf "Error: %a\n%!" Parser.pp_error e - | Result.Ok ast -> - Stdlib.Format.printf "Parsed result: %a\n%!" Printast.pp_named ast; - (match eval ast with - | rez -> Stdlib.Format.printf "Evaluated result: %a\n%!" Printast.pp_named rez) -;; - -type strategy = - | CBN - | CBV - | NO - | AO - -type opts = - { mutable batch : bool - ; mutable stra : strategy - } - -let () = - let opts = { batch = false; stra = CBN } in - let open Stdlib.Arg in - parse - [ ( "-" - , Unit (fun () -> opts.batch <- true) - , "Read from stdin single program, instead of running full REPL" ) - ; "-cbv", Unit (fun () -> opts.stra <- CBV), "Call-by-value strategy" - ; "-cbn", Unit (fun () -> opts.stra <- CBN), "Call-by-name strategy" - ; "-no", Unit (fun () -> opts.stra <- NO), "Normal Order strategy" - ; "-ao", Unit (fun () -> opts.stra <- NO), "Applicative Order strategy" - ] - (fun _ -> - Stdlib.Format.eprintf "Positioned arguments are not supported\n"; - Stdlib.exit 1) - "Read-Eval-Print-Loop for Utyped Lambda Calculus"; - let eval = - Lambda.apply_strat - (match opts.stra with - | NO -> Lambda.nor_strat - | CBV -> Lambda.cbv_strat - | AO -> Lambda.ao_strat - | CBN -> Lambda.cbn_strat) - in - (if opts.batch then run_single else run_repl) eval -;; diff --git a/named and optional arguments/demos/demoAO.ml b/named and optional arguments/demos/demoAO.ml deleted file mode 100644 index f0b67058f..000000000 --- a/named and optional arguments/demos/demoAO.ml +++ /dev/null @@ -1,121 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let ao_small_step_strat = - let rec helper = function - | Var _ as l -> fin l - | Abs (x, b) -> - (match helper b with - | WIP b2 -> wip (abs x b2) - | Done b2 -> fin (abs x b2)) - | App (f, arg) -> - (match helper f with - | WIP f2 -> wip (app f2 arg) - | Done (Abs (x, body)) -> - (match helper arg with - | Done arg -> wip (subst x ~by:arg body) - | WIP arg -> wip (app f arg)) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module _ = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - - let plus = - abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app m @@ app f @@ app n @@ app f x - ;; - - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* TODO: write the right if-then-else - by adding thunk around then and else branches to delay the evaluation *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let zed = - let hack = abs "x" (app f (abs "y" (app (app x x) y))) in - abs "f" (app hack hack) - ;; - - let () = test ao_strat @@ zero |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let () = test ao_strat @@ one |> fun lam -> Format.printf "%a\n%!" Pprintast.pp lam - let _ = test ao_strat @@ app plus @@ app one one |> Format.printf "%a\n%!" Pprintast.pp - - let () = - test ao_strat @@ app isZero @@ app one @@ app two three - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul one) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - let () = - test ao_small_step_strat @@ app (app mul three) two - |> Format.printf "%a\n%!" Pprintast.pp - ;; - - (* let () = - test ao_small_step_strat @@ app zed fact |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) - - (* let () = - test ao_small_step_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in - *) - (* let () = - test ao_strat @@ (app isZero zero) |> fun lam -> - Format.printf "%a\n%!" pp_lam lam - in *) -end diff --git a/named and optional arguments/demos/demoNO.ml b/named and optional arguments/demos/demoNO.ml deleted file mode 100644 index 7c14de53d..000000000 --- a/named and optional arguments/demos/demoNO.ml +++ /dev/null @@ -1,81 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib -open Ast -open Lambda -open Utils - -type 'a status = - | Done of 'a - | WIP of 'a - -let fin x = Done x -let wip x = WIP x - -let nor_small_step_strat = - let rec helper = function - | (Var _ as l) | (Abs (_, _) as l) -> fin l - | App (f, arg) -> - (match helper f with - | WIP f2 -> fin (app f2 arg) - | Done (Abs (x, e)) -> wip (subst x ~by:arg e) - | Done f2 -> fin (App (f2, arg))) - in - let rec loop t = - match helper t with - | Done x -> x - | WIP x -> - Format.printf " -- %a\n%!" Pprintast.pp x; - loop x - in - let on_app _ f arg = loop (app f arg) in - let on_abs _ f x = loop (abs f x) in - let on_var _ x = loop (var x) in - { on_var; on_abs; on_app } -;; - -let test strat term = - Format.printf "Evaluating: %a\n%!" Pprintast.pp term; - let rez = apply_strat strat term in - Format.printf "Result: %a\n%!" Pprintast.pp rez; - rez -;; - -module Std = struct - let zero = abs "g" @@ abs "y" @@ Var "y" - let one = abs "f" @@ abs "x" @@ app f (Var "x") - let two = abs "f" @@ abs "x" @@ app f (app f x) - let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) - let plus = abs "m" @@ abs "n" @@ abs "f" @@ abs "x" @@ app (app m f) (app (app n f) x) - let mul = abs "x" @@ abs "y" @@ abs "z" @@ app x (app y z) - let true_ = abs "x" @@ abs "y" @@ Var "x" - let false_ = abs "x" @@ abs "y" @@ Var "y" - let isZero = abs "n" @@ app (app n (abs "x" false_)) true_ - - (* if-then-else for lazy strategy *) - let ite cond th el = app (app (app isZero cond) th) el - - let pred = - let xxx = abs "g" @@ abs "h" @@ app h (app g f) in - abs "n" @@ abs "f" @@ abs "x" @@ app (app (app n xxx) (abs "u" x)) (abs "u" (Var "u")) - ;; - - let fact = - abs "self" - @@ abs "N" - @@ ite (Var "N") one (app (app mul (app (var "self") (app pred (var "N")))) (var "N")) - ;; - - let ygrek = - let hack = abs "x" (app f (app x x)) in - abs "f" (app hack hack) - ;; - - (* 5! = 120 *) - let () = - test nor_strat @@ app (app ygrek fact) (app (app plus two) three) - |> Format.printf "%a\n%!" Pprintast.pp - ;; -end diff --git a/named and optional arguments/demos/demoParse.ml b/named and optional arguments/demos/demoParse.ml deleted file mode 100644 index 0f1d3c1bf..000000000 --- a/named and optional arguments/demos/demoParse.ml +++ /dev/null @@ -1,12 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: CC0-1.0 *) - -open Lambda_lib - -let () = - let s = Stdio.In_channel.input_all Stdlib.stdin in - match Lambda_lib.Parser.parse s with - | Result.Ok ast -> Format.printf "%a\n%!" Printast.pp_named ast - | Error _ -> Format.printf "Some error" -;; diff --git a/named and optional arguments/demos/demo_input.txt b/named and optional arguments/demos/demo_input.txt deleted file mode 100644 index a8c3ab6bf..000000000 --- a/named and optional arguments/demos/demo_input.txt +++ /dev/null @@ -1 +0,0 @@ -Dummy text, it doesn't affect execution of ./demoAO.exe diff --git a/named and optional arguments/demos/dune b/named and optional arguments/demos/dune deleted file mode 100644 index b5aae5ae0..000000000 --- a/named and optional arguments/demos/dune +++ /dev/null @@ -1,39 +0,0 @@ -(executable - (name demoAO) - (modules demoAO) - (public_name demoAO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoNO) - (modules demoNO) - (public_name demoNO) - (libraries lambda_lib) - (instrumentation - (backend bisect_ppx))) - -(executable - (name demoParse) - (modules demoParse) - (public_name demoParse) - (libraries lambda_lib stdio) - (instrumentation - (backend bisect_ppx))) - -(cram - (applies_to interpretTests) - (deps - ./demoNO.exe - ./demoAO.exe - ./demoParse.exe - ../REPL.exe - ./demo_input.txt)) - -(cram - (applies_to parsingTests) - (deps - ./demoParse.exe - ; - )) diff --git a/named and optional arguments/demos/interpretTests.t b/named and optional arguments/demos/interpretTests.t deleted file mode 100644 index 3ac1647b4..000000000 --- a/named and optional arguments/demos/interpretTests.t +++ /dev/null @@ -1,49 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Cram tests here. They run and compare program output to the expected output -https://dune.readthedocs.io/en/stable/tests.html#cram-tests -Use `dune promote` after you change things that should runned - -If you need to put sample program and use it both in your interpreter and preinstalled one, -you could put it into separate file. Thise will need stanza `(cram (deps demo_input.txt))` -in the dune file - $ cat demo_input.txt - Dummy text, it doesn't affect execution of ./demoAO.exe - $ ./demoAO.exe < demo_input.txt - Evaluating: ⊥ - Result: ⊥ - ⊥ - Evaluating: 1 - Result: 1 - 1 - Evaluating: ((λ m n f x -> (m (f (n (f x))))) (1 1)) - Result: (λ n f x _x -> ((f (n (f x))) _x)) - (λ n f x _x -> ((f (n (f x))) _x)) - Evaluating: ((λ n -> ((n (λ _ _ y -> y)) ⊤)) (1 (2 (λ f x -> (f (f (f x))))))) - Result: ⊥ - ⊥ - Evaluating: (((λ x y z -> (x (y z))) 1) 2) - -- ((λ y z -> (1 (y z))) 2) - -- ((λ y z x -> ((y z) x)) 2) - -- (λ z x -> ((2 z) x)) - -- (λ z x -> ((λ x -> (z (z x))) x)) - -- 2 - Result: 2 - 2 - Evaluating: (((λ x y z -> (x (y z))) (λ f x -> (f (f (f x))))) 2) - -- ((λ y z -> ((λ f x -> (f (f (f x)))) (y z))) 2) - -- ((λ y z x -> ((y z) ((y z) ((y z) x)))) 2) - -- (λ z x -> ((2 z) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((2 z) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((2 z) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) ((λ x -> (z (z x))) x)))) - -- (λ z x -> ((λ x -> (z (z x))) ((λ x -> (z (z x))) (z (z x))))) - -- (λ z x -> ((λ x -> (z (z x))) (z (z (z (z x)))))) - -- (λ z x -> (z (z (z (z (z (z x))))))) - Result: (λ z x -> (z (z (z (z (z (z x))))))) - (λ z x -> (z (z (z (z (z (z x))))))) - $ ./demoNO.exe - Evaluating: (((λ f -> ((λ x -> (f (x x))) (λ x -> (f (x x))))) (λ self N -> ((((λ n -> ((n (λ _ _ y -> y)) ⊤)) N) 1) (((λ x y z -> (x (y z))) (self ((λ n f x -> (((n (λ g h -> (h (g f)))) (λ _ -> x)) (λ u -> u))) N))) N)))) (((λ m n f x -> ((m f) ((n f) x))) 2) (λ f x -> (f (f (f x)))))) - Result: (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - (λ z x -> (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z (z x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) diff --git a/named and optional arguments/demos/parsingTests.t b/named and optional arguments/demos/parsingTests.t deleted file mode 100644 index 1ba9de4f8..000000000 --- a/named and optional arguments/demos/parsingTests.t +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2021-2022, Kakadu and contributors -SPDX-License-Identifier: CC0-1.0 - -Tests about parsing go here. It's expected that programs parse something and -output a parse tree. -For example, where your test correctness of AST it's recommend to put both -input and output into this file. In this case it will be easier to check that -answer is correct - - $ ./demoParse.exe <<-EOF - > (λf.λx. f (x x)) - > EOF - (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) diff --git a/named and optional arguments/dune b/named and optional arguments/dune deleted file mode 100644 index ac0fa4ca0..000000000 --- a/named and optional arguments/dune +++ /dev/null @@ -1,16 +0,0 @@ -(env - (dev - (flags - (:standard -warn-error -A -w -3-9-32-34-58))) - (release - (flags - (:standard -warn-error -A -w -58)))) - -(executable - (name REPL) - (public_name REPL) - (modules REPL) - (libraries Lambda.Lib stdio)) - -(cram - (deps ./REPL.exe %{bin:REPL})) diff --git a/named and optional arguments/dune-project b/named and optional arguments/dune-project deleted file mode 100644 index d9486c363..000000000 --- a/named and optional arguments/dune-project +++ /dev/null @@ -1,34 +0,0 @@ -(lang dune 3.7) - -(generate_opam_files true) - -(cram enable) - -(license LGPL-3.0-or-later) - -(authors "FIXME Vasya Pupkin") - -(maintainers "FIXME Vasya Pupkin") - -(bug_reports "FIXME where to put bug reports about the code") - -(homepage "FIXME Homepage") - -(package - (name Lambda) ; FIXME and regenerate .opam file using 'dune build @install' - (synopsis "FIXME An interpreter for language") - (description - "FIXME. A longer description, for example, which are the most interesing features being supported, etc.") - (version 0.1) - (depends - dune - angstrom - (ppx_inline_test :with-test) - ppx_expect - ppx_deriving - bisect_ppx - (odoc :with-doc) - (ocamlformat :build) - ; base - ; After adding dependencies to 'dune' files and the same dependecies here too - )) diff --git a/named and optional arguments/lib/Pprintast.ml b/named and optional arguments/lib/Pprintast.ml deleted file mode 100644 index fe7d24716..000000000 --- a/named and optional arguments/lib/Pprintast.ml +++ /dev/null @@ -1,55 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* Pretty printer goes here *) - -open Ast -open Utils - -let pp = - let mangle t fmt x = - if is_free_in x t then Format.fprintf fmt "%s" x else Format.fprintf fmt "_" - in - let rec pp fmt = function - | Var s -> Format.fprintf fmt "%s" s - | App (l, r) -> Format.fprintf fmt "(%a %a)" pp l pp r - | Abs (x, Abs (y, Var z)) when x = z && y <> z -> Format.fprintf fmt "⊤" - | Abs (x, Abs (y, Var z)) when y = z && x <> z -> Format.fprintf fmt "⊥" - | Abs (f, Abs (x, Var z)) when x = z && x <> f -> Format.fprintf fmt "0" - | Abs (f, Abs (x, App (Var g, Var z))) when x = z && x <> f && g = f -> - Format.fprintf fmt "1" - | Abs (f, Abs (x, App (Var g, App (Var h, Var z)))) - when x = z && x <> f && g = f && h = g -> Format.fprintf fmt "2" - | Abs (v1, Abs (v2, Abs (v3, Abs (v4, t)))) -> - Format.fprintf - fmt - "(λ %a %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - (mangle t) - v4 - pp - t - | Abs (v1, Abs (v2, Abs (v3, t))) -> - Format.fprintf - fmt - "(λ %a %a %a -> %a)" - (mangle t) - v1 - (mangle t) - v2 - (mangle t) - v3 - pp - t - | Abs (v1, Abs (v2, t)) -> - Format.fprintf fmt "(λ %a %a -> %a)" (mangle t) v1 (mangle t) v2 pp t - | Abs (x, t) -> Format.fprintf fmt "(λ %a -> %a)" (mangle t) x pp t - in - pp -;; diff --git a/named and optional arguments/lib/Pprintast.mli b/named and optional arguments/lib/Pprintast.mli deleted file mode 100644 index b50e36629..000000000 --- a/named and optional arguments/lib/Pprintast.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val pp : Format.formatter -> string Ast.t -> unit diff --git a/named and optional arguments/lib/Printast.ml b/named and optional arguments/lib/Printast.ml deleted file mode 100644 index 04c862fdb..000000000 --- a/named and optional arguments/lib/Printast.ml +++ /dev/null @@ -1,11 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type 'name t = 'name Ast.t = - | Var of 'name - | Abs of 'name * 'name t - | App of 'name t * 'name t -[@@deriving show { with_path = false }] - -let pp_named = pp Format.pp_print_string diff --git a/named and optional arguments/lib/Printast.mli b/named and optional arguments/lib/Printast.mli deleted file mode 100644 index 80eac9c8f..000000000 --- a/named and optional arguments/lib/Printast.mli +++ /dev/null @@ -1,9 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Pretty-print representation of AST with names. *) -val pp_named : Format.formatter -> string Ast.t -> unit - -val pp : (Format.formatter -> 'name -> unit) -> Format.formatter -> 'name Ast.t -> unit -val show : (Format.formatter -> 'name -> unit) -> 'name Ast.t -> string diff --git a/named and optional arguments/lib/ast.mli b/named and optional arguments/lib/ast.mli deleted file mode 100644 index d661d6cce..000000000 --- a/named and optional arguments/lib/ast.mli +++ /dev/null @@ -1,15 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type name = string - -(** The main type for our AST (дерева абстрактного синтаксиса) *) -type 'name t = - | Var of 'name (** Variable [x] *) - | Abs of 'name * 'name t (** Abstraction [λx.t] *) - | App of 'name t * 'name t - -(* Application [f g ] *) -(** In type definition above the 3rd constructor is intentionally without documentation -to test linter *) diff --git a/named and optional arguments/lib/dune b/named and optional arguments/lib/dune deleted file mode 100644 index e6f215765..000000000 --- a/named and optional arguments/lib/dune +++ /dev/null @@ -1,20 +0,0 @@ -(library - (name lambda_lib) - (public_name Lambda.Lib) - (modules Ast Lambda Interpret Parser Printast Pprintast utils) - (modules_without_implementation ast) - (libraries base angstrom) - (preprocess - (pps ppx_deriving.show)) - (instrumentation - (backend bisect_ppx))) - -(library - (name tests) - (modules tests) - (libraries lambda_lib) - (preprocess - (pps ppx_expect ppx_deriving.show)) - (instrumentation - (backend bisect_ppx)) - (inline_tests)) diff --git a/named and optional arguments/lib/interpret.ml b/named and optional arguments/lib/interpret.ml deleted file mode 100644 index 247625c77..000000000 --- a/named and optional arguments/lib/interpret.ml +++ /dev/null @@ -1,31 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** Real monadic interpreter goes here *) - -open Utils - -type error = [ `UnknownVariable of string (** just for example *) ] - -module Interpret (M : MONAD_FAIL) : sig - val run : _ Ast.t -> (int, [> error ]) M.t -end = struct - let run _ = - (* TODO: implement interpreter here *) - if true then M.fail (`UnknownVariable "var") else failwith "not implemented" - ;; -end - -let parse_and_run str = - let module I = Interpret (Base.Result) in - let rez = Base.Result.(Parser.parse str >>= I.run) in - match rez with - | Result.Ok n -> Printf.printf "Success: %d\n" n - | Result.Error #Parser.error -> - Format.eprintf "Parsing error\n%!"; - exit 1 - | Result.Error #error -> - Format.eprintf "Interpreter error\n%!"; - exit 1 -;; diff --git a/named and optional arguments/lib/interpret.mli b/named and optional arguments/lib/interpret.mli deleted file mode 100644 index 0a6b3f817..000000000 --- a/named and optional arguments/lib/interpret.mli +++ /dev/null @@ -1,5 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -val parse_and_run : string -> unit diff --git a/named and optional arguments/lib/lambda.ml b/named and optional arguments/lib/lambda.ml deleted file mode 100644 index 37849a49c..000000000 --- a/named and optional arguments/lib/lambda.ml +++ /dev/null @@ -1,119 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Ast -open Base -open Utils - -(* Smart constructors *) -let var x = Var x -let abs x y = Abs (x, y) -let app x y = App (x, y) - -let replace_name x ~by = - let rec helper = function - | Var y when String.equal x y -> Var by - | Var t -> Var t - | App (l, r) -> App (helper l, helper r) - | Abs (y, t) when String.equal x y -> Abs (by, helper t) - | Abs (z, t) -> Abs (z, helper t) - in - helper -;; - -let rec next_name s old = - if List.mem ~equal:String.equal old s then next_name ("_" ^ s) old else s -;; - -(* The call [subst x ~by:v e] means `[x/v]e` or `e[v -> x]` *) -let subst x ~by:v = - let rec helper e = - match e with - | Var y when String.equal y x -> v - | Var y -> Var y - | App (l, r) -> app (helper l) (helper r) - | Abs (y, b) when String.equal y x -> abs y b - | Abs (y, t) when is_free_in y v -> - let frees = free_vars v @ free_vars t in - let w = next_name y frees in - helper (abs w (replace_name y ~by:w t)) - | Abs (y, b) -> abs y (helper b) - in - helper -;; - -type strat = - { on_var : strat -> name -> string Ast.t - ; on_abs : strat -> name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -let apply_strat st = function - | Var name -> st.on_var st name - | Abs (x, b) -> st.on_abs st x b - | App (l, r) -> st.on_app st l r -;; - -let without_strat = - let on_var _ = var in - let on_abs _ = abs in - let on_app _ = app in - { on_var; on_abs; on_app } -;; - -let cbn_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> apply_strat st (subst x ~by:arg e) - | f2 -> App (f2, arg) - in - { without_strat with on_app } -;; - -let under_abstraction st x b = abs x (apply_strat st b) - -(* Normal Order Reduction to Normal Form - Application function reduced as CBN first - + Reduce under abstractions *) -let nor_strat = - let on_app st f arg = - match apply_strat cbn_strat f with - | Abs (x, e) -> apply_strat st @@ subst x ~by:arg e - | f1 -> - let f2 = apply_strat st f1 in - let arg2 = apply_strat st arg in - App (f2, arg2) - in - { without_strat with on_app; on_abs = under_abstraction } -;; - -(* Call-by-Value Reduction to Weak Normal Form *) -let cbv_strat = - let on_app st f arg = - match apply_strat st f with - | Abs (x, e) -> - let arg2 = apply_strat st arg in - apply_strat st @@ subst x ~by:arg2 e - | f2 -> App (f2, apply_strat st arg) - in - { without_strat with on_app } -;; - -(* Applicative Order Reduction to Normal Form - As CBV but reduce under abstractions *) -let ao_strat = { cbv_strat with on_abs = under_abstraction } -let a = var "a" -let x = var "x" -let y = var "y" -let z = var "z" -let f = var "f" -let g = var "g" -let h = var "h" -let m = var "m" -let n = var "n" -let p = var "p" -let zero = abs "f" @@ abs "x" x -let one = abs "f" @@ abs "x" @@ app f x -let two = abs "f" @@ abs "x" @@ app f (app f x) -let three = abs "f" @@ abs "x" @@ app f (app f (app f x)) diff --git a/named and optional arguments/lib/lambda.mli b/named and optional arguments/lib/lambda.mli deleted file mode 100644 index cbf209907..000000000 --- a/named and optional arguments/lib/lambda.mli +++ /dev/null @@ -1,43 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t *) - -val subst : string -> by:string Ast.t -> string Ast.t -> string Ast.t - -type strat = - { on_var : strat -> Ast.name -> string Ast.t - ; on_abs : strat -> Ast.name -> string Ast.t -> string Ast.t - ; on_app : strat -> string Ast.t -> string Ast.t -> string Ast.t - } - -val apply_strat : strat -> string Ast.t -> string Ast.t -val without_strat : strat - -(** Predefined strategies *) - -val cbn_strat : strat -val nor_strat : strat -val cbv_strat : strat -val ao_strat : strat - -(** Example lambda expressions *) - -val a : string Ast.t -val x : string Ast.t -val y : string Ast.t -val z : string Ast.t -val f : string Ast.t -val g : string Ast.t -val h : string Ast.t -val m : string Ast.t -val n : string Ast.t -val p : string Ast.t -val zero : string Ast.t -val one : string Ast.t -val two : string Ast.t -val three : string Ast.t diff --git a/named and optional arguments/lib/parser.ml b/named and optional arguments/lib/parser.ml deleted file mode 100644 index f49273b50..000000000 --- a/named and optional arguments/lib/parser.ml +++ /dev/null @@ -1,65 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(* TODO: implement parser here *) -open Angstrom - -let is_space = function - | ' ' | '\t' | '\n' | '\r' -> true - | _ -> false -;; - -let spaces = skip_while is_space - -let varname = - satisfy (function - | 'a' .. 'z' -> true - | _ -> false) -;; - -let conde = function - | [] -> fail "empty conde" - | h :: tl -> List.fold_left ( <|> ) h tl -;; - -type dispatch = - { apps : dispatch -> string Ast.t Angstrom.t - ; single : dispatch -> string Ast.t Angstrom.t - } - -type error = [ `ParsingError of string ] - -let pp_error ppf = function - | `ParsingError s -> Format.fprintf ppf "%s" s -;; - -let parse_lam = - let single pack = - fix (fun _ -> - conde - [ char '(' *> pack.apps pack <* char ')' - ; ((string "λ" <|> string "\\") *> spaces *> varname - <* spaces - <* char '.' - >>= fun var -> - pack.apps pack >>= fun b -> return (Ast.Abs (String.make 1 var, b))) - ; (varname <* spaces >>= fun c -> return (Ast.Var (String.make 1 c))) - ]) - in - let apps pack = - many1 (spaces *> pack.single pack <* spaces) - >>= function - | [] -> fail "bad syntax" - | x :: xs -> return @@ List.fold_left (fun l r -> Ast.App (l, r)) x xs - in - { single; apps } -;; - -let parse str = - match - Angstrom.parse_string (parse_lam.apps parse_lam) ~consume:Angstrom.Consume.All str - with - | Result.Ok x -> Result.Ok x - | Error er -> Result.Error (`ParsingError er) -;; diff --git a/named and optional arguments/lib/parser.mli b/named and optional arguments/lib/parser.mli deleted file mode 100644 index 7c657cc6d..000000000 --- a/named and optional arguments/lib/parser.mli +++ /dev/null @@ -1,18 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -type error = [ `ParsingError of string ] - -val pp_error : Format.formatter -> [< `ParsingError of string ] -> unit - -(** Main entry of parser *) -val parse : string -> (Ast.name Ast.t, [> error ]) result - -type dispatch = - { apps : dispatch -> Ast.name Ast.t Angstrom.t - ; single : dispatch -> Ast.name Ast.t Angstrom.t - } - -(* A collection of miniparsers *) -val parse_lam : dispatch diff --git a/named and optional arguments/lib/tests.ml b/named and optional arguments/lib/tests.ml deleted file mode 100644 index 6b51ab055..000000000 --- a/named and optional arguments/lib/tests.ml +++ /dev/null @@ -1,40 +0,0 @@ -(** Copyright 2021-2022, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -(** ***** UNIT TESTS COULD GO HERE (JUST AN EXAMPLE) *) -let rec fact n = if n = 1 then 1 else n * fact (n - 1) - -let%test _ = fact 5 = 120 - -(* These is a simple unit test that tests a single function 'fact' - If you want to test something large, like interpretation of a piece - of a minilanguge, it is not longer a unit tests but an integration test. - Read about dune's cram tests and put the test into `demos/somefile.t`. -*) - -open Lambda_lib -open Parser - -let parse_optimistically str = Result.get_ok (parse str) -let pp = Printast.pp_named - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "x y"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(x y)"); - [%expect {| (App ((Var x), (Var y))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(\\x . x x)"); - [%expect {| (Abs (x, (App ((Var x), (Var x))))) |}] -;; - -let%expect_test _ = - Format.printf "%a" pp (parse_optimistically "(λf.λx. f (x x))"); - [%expect {| (Abs (f, (Abs (x, (App ((Var f), (App ((Var x), (Var x))))))))) |}] -;; diff --git a/named and optional arguments/lib/utils.ml b/named and optional arguments/lib/utils.ml deleted file mode 100644 index 06f1d16be..000000000 --- a/named and optional arguments/lib/utils.ml +++ /dev/null @@ -1,30 +0,0 @@ -(** Copyright 2021-2023, Kakadu and contributors *) - -(** SPDX-License-Identifier: LGPL-3.0-or-later *) - -open Base -open Ast - -(* TODO: use a set instead of list *) -let list_remove x = List.filter ~f:(fun a -> not (String.equal a x)) - -let free_vars = - let rec helper acc = function - | Var s -> s :: acc - | Abs (s, l) -> acc @ list_remove s (helper [] l) - | App (l, r) -> helper (helper acc r) l - in - helper [] -;; - -let is_free_in x term = List.mem (free_vars term) x ~equal:String.equal -let var x = Var x -let abs x l = Abs (x, l) -let app l r = App (l, r) - -(* TODO: rework this *) -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/named and optional arguments/lib/utils.mli b/named and optional arguments/lib/utils.mli deleted file mode 100644 index 3ad28d0d9..000000000 --- a/named and optional arguments/lib/utils.mli +++ /dev/null @@ -1,14 +0,0 @@ -val free_vars : string Ast.t -> string list -val is_free_in : string -> string Ast.t -> bool - -(** Smart constructors *) - -val var : 'a -> 'a Ast.t -val abs : 'a -> 'a Ast.t -> 'a Ast.t -val app : 'a Ast.t -> 'a Ast.t -> 'a Ast.t - -module type MONAD_FAIL = sig - include Base.Monad.S2 - - val fail : 'e -> ('a, 'e) t -end diff --git a/named and optional arguments/repl.t b/named and optional arguments/repl.t deleted file mode 100644 index b7f021184..000000000 --- a/named and optional arguments/repl.t +++ /dev/null @@ -1,24 +0,0 @@ - - $ ./REPL.exe - OCaml-style toplevel (ocamlc, utop) is not implemented - $ ./REPL.exe -help - Read-Eval-Print-Loop for Utyped Lambda Calculus - - Read from stdin single program, instead of running full REPL - -cbv Call-by-value strategy - -cbn Call-by-name strategy - -no Normal Order strategy - -ao Applicative Order strategy - -help Display this list of options - --help Display this list of options - $ ./REPL.exe -cbv - < \f.x - Parsed result: (Abs (f, (Var x))) - Evaluated result: (Abs (f, (Var x))) - $ ./REPL.exe -no - < (\x.\y.x)(\u.u)((\x. x x)(\x.x x)) - Parsed result: (App ( - (App ((Abs (x, (Abs (y, (Var x))))), (Abs (u, (Var u))))), - (App ((Abs (x, (App ((Var x), (Var x))))), - (Abs (x, (App ((Var x), (Var x))))))) - )) - Evaluated result: (Abs (u, (Var u))) diff --git a/tasks.md b/tasks.md deleted file mode 100644 index dfd32cf2a..000000000 --- a/tasks.md +++ /dev/null @@ -1,816 +0,0 @@ -## Темы задач на самостоятельную работу - -Ниже нарочито неформально даны описания мини-языков, интерпретатор которых вам предстоит реализовать на OCaml, чтобы получить допуск к финальной аттестации (экзамену). - -Запись на тему делается добавлением в этот репо PR (желательно, проходящего CI). Кто первый успел, того и тапки. Не забудьте ФИО. Как правильно оформлять PR читайте в [README](/README.md). -(Если вы сможете сами их распределить в форме Excel-таблички и не поругаться, то можно и без PRов.) - -Темы задач выдаются на одного человека (если не оговорено иное), т.е. почти у всех самостоятельная работа будет разная. Если вера в собственные силы крайне мала, есть **одна отдельная тема для всех** тех, **кому достаточно** получить после экзамена максимальную оценку **D**. Потом можно передумать и переписаться на другую незанятую задачу (в том числе и на максимум D). - -Во всех работах, где надо писать инерпретатор типизированного языка, надо писать тайпчекер тоже. Скорее всего он будет запускаться до интерпретатора. Проверки типов, которые можно сделать на фазе типизации, нужно делать на фазе типизации, их нельзя делать в интерпретаторе. - - -### Тема для D - -Задача выдается, если вас устраивает итоговая оценка не выше D. Данная тема выдается неограниченному кругу студентов. - -Реализовать синтаксический анализатор (парсер), type checker и интерпретатор языка miniML, в котором поддерживаются следующие конструкции. - -* Функции как объекты первого класса (first class citizens): их нужно уметь передавать и возвращать из функций. Замыкания также нужны -* Стандартные типы данных: bool, int и n-ки (англ. tuples) -* Стандартные функции, чтобы что-нибудь напечатать по ходу интепретации (печать строки, печать числа и т.п.). -* Захардкоженный тип связного списка, сопоставление с образцом по нему. Полноценные алгебраические типы не надо. -* Во всех задачах про OCaml, аргумент ~~анонимной~~ функции является так называемым паттерном (англ. pattern). Выражения там разрешать писать нельзя! - -Для этой задачи выбирайте имя директории в виде ``DФамилия'' латиницей. - -### Основные домашки - -1. OCaml + ADT
Подробнее - * Всё, что есть в теме для D - * алгебраические типы как основной способ проектирования типов; учтите, что - * в OCaml и Haskell типы int и float -- примитивные (встроенные) - * тип списков алгебраический и там, и там; в AST не должно быть, что списки отдельно, а алгебраические значения отдельно - * в OCaml тип bool примитивный, а в Haskell -- алгебраический - * разумеется, объявления типов, паттерн-мэтчинг и типизация - * присваивание не надо - * исключения не надо -
-1. OCaml + Extensible variant types
Подробнее - * Всё, что есть в теме для D - * [Recursive definitions of values](https://v2.ocaml.org/manual/letrecvalues.html). Плохой синтаксис должен выдавать ошибку типизации. В простенькие бесконечные списки должно быть можно загрянуть. -
-1. OCaml + Recursive values
Подробнее - * Всё, что есть в теме для D - * алгебраические типы заменены на extensible variants -
-1. OCaml + полиморфные вариантые типы
Подробнее - * Всё, что есть в теме для D - * [Глава про полиморфные варианты в мануале OCaml](https://v2.ocaml.org/manual/polyvariant.html) - * Объявления типов можно не делать - * Стандартные типы (пары, списки, option) можно делать, а можно не делать, выразив через полиморфные варианты -
-1. OCaml + bidirectional records
Подробнее - * Всё, что есть в теме для D - * поддержать синтаксис приписывания (англ. ascription) типов переменным - * records (a.k.a. записи, структуры) c полями из базовых типов или других записей. - * в случае перекрытия имен интерпретатор должен учесть приписанные типы. В примере ниже без аннотаций типов результат вывода будет другой - ```ocaml - type t = { aa: int; bb: bool } - type s = { aa: float; cc: int } - let f (x : t) = x.aa - let g (x : s) = x.aa - ``` -
-1. F# + active patterns
Подробнее - * Всё, что есть в теме для D - * возможность описывать [активные паттерны](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/active-patterns), которые выглядят как алгебраические конструкторы - ``` - let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd - ``` - * Возможность использования активных паттернов в сопоставлении с образцом - ``` - let TestNumber = function - | Even -> printf "%d is even\n" input - | Odd -> printf "%d is odd\n" input - ``` -
-1. Haskell + стандартные типы данных + ленивость
Подробнее - * Всё, что есть в теме для D - * С ленивостью надо будет продемонстрировать работоспособность - * Лямбда-исчисления с call-by-name - * ленивых списков и операция над ними (в том числе, фибоначчи, решето Эратосфена и т.п.) - * прочие ленивые задачи (например, за один проход заменить все числа в дереве на их минимум и вернуть новое дерево) -
-1. OCaml + [ООП](https://v2.ocaml.org/manual/objectexamples.html)
Подробнее - * Всё, что есть в теме для D, кроме n-ок. - * в OCaml есть интересные объекты и их типизация, нужно поддержать объекты+методы+поля. - * (может быть классы и наследование тоже надо будет, но пока не уверен) - * как тесты предлагаю реализовать некоторые структуры данных как камлёвые объекты и посмотреть, что будет -
-1. OCaml + effects (2 человека)
Подробнее - * Всё, что есть в теме для D - * Cупер-модное в наши дни движение в мире ФП - * По сути, это исключения, но в момент обработки которых у нас есть функция, которой можно был передать значение, которое должно было бы быть вместо бросания исключения, и продолжить исполнение с места бросания исключения. - * Туториал в контексте OCaml https://github.com/ocamllabs/ocaml-effects-tutorial - * два человека только потому, что хочу чтобы задачу кто-то взял. А так это **очень** сильно напоминает задачи про delim/cc -
-1. -1. OCaml + printf
Подробнее - * Всё, что есть в теме для D - * Поддержка типов char, string и операций с ними - * Поддержка в компиляторе функции форматированой печати (по аналогии с камлёвым модулем Printf/Format). Разумеется, всё должно быть type safe. -
-1. OCaml, именованые и опциональные аргументы
Подробнее - * Всё, что есть в теме для D - * Захардкоженный тип option - * Именованные и опциональные аргументы. Функции должны типизироваться и исполняться как в настоящем OCaml. -
-1. OCaml с типизированными эффектами (2 человека)
Выглядит страшно, но в 2021 году человек в одиночку справился - * Всё, что есть в теме для D - * C эффектами: присваивание, печать на консоль и try/catch/raise для пары захардкоженных в язык исключений. Из-за присваивания -- два человека - * С системой типов в описанном выше смысле. - * https://www.janestreet.com/tech-talks/effective-programming - * Идея заключается в том, что теперь мы будем перечислять в типе функции-стрелке эффекты, которые совершает функция - * Обычная стрелка `->` делает что угодно - * Длинная стрелка `-->` (или `-[]->`) -- это чистая функция: ни присваиваний, ни ввода-вывода. Ничего не делает такого. - * Над стрелкой можно перечислять, что она делает: - * `-[IO]->` делает ввод-вывод - * `-[exc Not_found]->` кидает исключение `Not_found` - * `-['a]->` совершает какой-то эффект, но он не указан (полиморфизм) - * Пример: - - ```ocaml - val id : 'a --> 'a - val print_int: int -[IO]-> unit - - let map : ('a -['e]-> 'b) --> 'a list -['e]-> 'b list = fun f xs -> - match xs with - | [] -> [] - | x::xs -> (f x) :: (map f xs) - - let _ : 'a list --> 'b list = map id - let _ : int list -[IO]-> int list = - map (fun n -> print_int n; n+1) - ``` - - Фунция `id` чистая, поэтому над стрелочкой ничего не написано. - - Функция `print_int` совершает ввод-вывод, что указано в типе. - - `List.map` полиморфна (как обычно) по типу элементу списка, но также полиморфная по типу эффекта переданной функции, что указано в стрелке, которая выдает результат. Первая стреклка в типе `map` чистая, так как при передаче аргументов ничего не вычисляется и эффектов не совершается. В `map id` не совешается эффектов, поэтому типовая переменная `'e` сунифицировалась с отсутсвием эффектов. Во втором примере из-за того, что переданная функция совершает ввод-вывод, система типов догадывается, что и вычисление `map` совершает ввод-вывод. - - Вы уже видели приписывание эффектов к функциям, а именно, приписывание бросаемых исключений в языке Java. Но так как там не было полиморфизма по этим "эффектам", то люди ненавидели эту штуку и поэтому, на сколько я знаю, в идеалогических наследниках Java этого нет. -
-1. -1. OCaml + weak type variables - * Всё, что есть в теме для D - * https://ocamlverse.net/content/weak_type_variables.html. Присваивание неоходимо, так как без него тема бессодержательна. -1. F# + Units of Measure
Подробнее - * Всё, что есть в теме для D - * Вещественные числа (обосновано следующим пунктом) - * Возможность объявлять и использовать [Units of Measure](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/units-of-measure) -
-1. OCaml + скомпилированные алгебраические типы
Подробнее - * (задача может показать объёмной, поэтому разрешаю сдавать в одной кодовой базе в месте с задаче про OCaml + ADT) - * Прочитать как окамлёвые алгебаические [типы представляются в памяти](https://dev.realworldocaml.org/runtime-memory-layout.html), разобраться как устроены "блоки" и unboxed immediate values - * Написать парсер (параметризовать уже существующий из другой задачи) который понимает функции для конструирования/заглядывания в блоки - * Интерпретатор - * Алгоритм преобразования программ с алгебраиками и сопоставлением с образцом в низкоуровневое представление. - * Преобразования программ из задачи про ADT, в низкоуровневое представление этой задачи. (По сути надо избавляться от алгебраических значений и сопоставления с образцом. Можно посмотреть алгоритм с матрицами [отсюда](https://www.researchgate.net/publication/2840783_Optimizing_Pattern_Matching) ) -
-1. Scheme + call/cc
Подробнее - * относительно легко гуглящаяся особенность Scheme - * call/cc - * целые числа, рекурсия, списки, печать на консоль - * функции обычные и анонимные, замыкания и рекурсия - * присваивание не надо - * quote/unquote - * парсер очень простой - * никаких статических типов, разумеется, нет - * учитывая следующую задачу, получается в некотором смысле на двоих -
-1. Scheme + delim/cc
Подробнее - * почти как предыдущая задача, только понятней - * Кратко про delim/cc - + есть две новые конструкции в языке: `reset (fun () -> M)` и `shift (fun k -> M)` - + Пример: `reset (fun () -> 2 + 2 * shift (fun k -> k 20))` - + Наличие одинокого `reset` не влияет на вычисление - + Когда исполнение доходит до `shift`, то вместо аргумета подставляется функция, которая "зажата" между этим `shift` и ближайшим `reset`, В даннои случае это `fun y -> 2 + 2 * y` - + таким образом, выражение выше вычисляется в 42 -
-1. Ассемблер x86_64
Подробнее - * Очень простой язык и для парсинга, не такой простой для реализации интерпретатора. - * Язык должен быть настоящим ассемблером, т. е. входные программы должны компилироваться соответствующим компилятором (nasm) и выдавать ответ как в интерпретаторе. Сделайте cram тесты, демонстрирующие это. - * Примеры в первую очередь берите из первой части книжки И. Жиркова "Low-level programming". Там должен быть helloworld, который требует syscall и память. - * Чтобы задача не была чересчур простой, хочу также в ассемблере SIMD операции и тесты к ним (перемножение вектора/матрицы на вектор/матрицу) - * Опыты прошлых лет показывает, что написание AST в лоб оставляет большое пространство для плохих программ, представимых в AST. Например, 64битные команды никак не должны принимать 32битные операнды-регистры как аргументы. Потребуется обмазаться фантомными-типами и/или GADT, чтобы не нужно было писать гавнокод. Буду следить! -
-1. Refal 5 - * одскульный отечественный язык программирования, где последовательности можно мэтчить не только с начала, но и с конца - * [здесь](http://refal.botik.ru/book/html/examples/examples.cgi?ex_index=0), есть 22 примера простых программ на рефал-5 - * а [здесь](http://refal.botik.ru/scp_demo/) есть програмки посложнее -1. Pascal c алгебраическими типами - * Числа, строки и операции с ними. Функции обычные и вложенные, с рекурсией. Вроде как по сравнению с miniML тут не будет вывода типов, только проверка типов. Присваивание не надо. - * алгебраические типы данных [variant records](https://www.bestprog.net/en/2016/10/10/records/#q12) (пункт 12). -1. Cи
Подробнее - * Целые числа разного размера (например, int32_t и int8_t) - * char - * Cтандартные конструкции: циклы, ветвления, прочие - * Указатели и арифметика указателей, malloc / free - * Продемонстрировать стандартные примеры программ на указатели - * Короткий memcpy и что с ним может пойти не так - * Реинтерпретировать кусок памяти с массивом int32_t как в 4 раза большее количество чисел int8_t - * Функции и рекурсия: факториал, фибоначчи, и т.п. - * Объявления пользовательских структур не надо. -
-1. Lua -- примитивный язык без статических типов
Подробнее - * Вещественные числа, строки - * Функции и функции высшего порядка - * Стандартные конструкции: ветвления, цикл и т.п. - * Присваивание и хитрые ассоциативные массивы с двойной индексацией, специфичные для Lua -
-1. Javascript (2 человека)
Подробнее - * Объекты, числа, строки, массивы (т.е. присваивание надо) - * Функции обычные и анонимные, замыкания, рекурсия - * Типичное для Javascript прототипное наследование - * Стрёмные штуки из [WAT talk](https://www.destroyallsoftware.com/talks/wat) и [отсюда](https://github.com/denysdovhan/wtfjs/blob/master/README.md#table-of-contents). Их будет много (постепенно добавлю) -
-1. Моделирование параллельного исполнения
Подробнее - За описание благодарите старшего студента. - * Ast - Программа состоит из N параллельных участков. В них бывает арифметика, присваивание, thread-local registers (отдельный для каждого потока набор регистров, например EAX, EBX или r1, r2), shared variables (переменные в которые могут писать и из которых могут читать сразу несколько потоков), ветвления и барьеры чтения/записи. - * Parser - Код потока записывается в столбик, код разных потоков разделен с помощью значка |||. Потоки исполняются параллельно. Если нет идей как такое парсить, то попробуйте следующий способ. Научитесь парсить один конкретный поток по его индексу (нулевой, первый, …, N-1й), потом используя эту функцию распарсите все потоки по очереди и получите список распаршеных потоков. - Пример кода на этом языке: - ``` - x <-1 ||| y<-1 - smp_mb ||| smp_mb - r1 <-y ||| r2<-x - ``` - - Здесь x,y это shared переменные. r1,r2 – локальные для потока регистры. smp_mb – барьер памяти. В этом примере 2 параллельных потока, в каждом потоке 3 инструкции. - * **Интерпретатор** - Не стоит пугаться, на самом деле вы будете исполнять по одной инструкции за раз чередуя потоки из которых эта инструкция берётся. Модель же памяти будет влиять на операции чтения и записи: эффекты этих операций могут проявляться не в те моменты времени, как вам подсказывает интуиция, из-за этого возникают интересные поведения. - Отмечу, что интерпретатор должен осуществить всевозможные исполнения переданной ему на вход программы, с этим поможет монада List (или другая монада для недетерминизма). - * Описание моделей памяти: - * Sequential Consistency – простейшая модель, выбираете произвольный поток и исполняете в нем одну инструкцию. Повторяете пока есть неисполненные инструкции. Барьеры памяти в этой модели не оказывают эффекта на исполнение программы. - * TSO – модель памяти процессоров x86. Здесь возможны интересные поведения. Если в примере выше изначально в переменных x и y хранятся значения ноль, а также из кода будут удалены инструкции барьеров памяти (smp_mb), то возможны поведения, в которых после исполнения будет x == 0 и y == 0. При наличии барьеров памяти после исполнения хотя бы одна переменная всегда будет иметь значение один. Вообще этот код называется store buffering test о нём и не только о нём можно прочесть в статье a better x86 memory model. - * **Полезные материалы:** - * [Открытая лекция «weak memory models»](https://youtu.be/P4AnGeVFbzo?list=PLlb7e2G7aSpRgsZVTYYbpqiFrIcIpf8kp) от Антона Подкопаева. В CSC тоже были лекции на эту тему: [раз](https://www.youtube.com/watch?v=VcesAbhnGKU&list=PLlb7e2G7aSpQCPeKTcVBHJns_JOxrc_fT&index=11) и [два](https://www.youtube.com/watch?v=kg0ZVbBdsMM&list=PLlb7e2G7aSpQCPeKTcVBHJns_JOxrc_fT&index=12). - * К двум лекциям от CSC необходимо добавить статью Memory Barriers: a Hardware View for Software Hackers ([http://www.puppetmastertrading.com/images/hwViewForSwHackers.pdf](http://www.puppetmastertrading.com/images/hwViewForSwHackers.pdf)) - * Статья расскажет о том, что такое store buffer(write buffer) и как работают барьеры памяти. [A better x86 memory model: x86-TSO (extended version)](https://www.cl.cam.ac.uk/~pes20/weakmemory/x86tso-paper.pdf). В ней можно найти тесты (litmus tests) для модели x86 и проверить свой интерпретатор - * [СТАТЬЯ, КОТОРАЯ МЕНЯЕТ ВСЁ!](https://habr.com/ru/company/JetBrains-education/blog/523298/) После прочтения этой статьи в конце 3й недели работы над домашкой. Я за 2 часа удалил 2/3 своего кода и получил работающие модели. Поэтому я уверен, что она может сильно помочь, после того, как всё предыдущее будет изучено и что-то будет написано. -
-1. Объектно-ориентированый C# c классами и интерфейсами
Подробнее - * Наследование классов и интерфейсов, без generics. - * public/private/protected и override. - * Стандартные конструкции языка + приведение типов объектов. - * Целые числа, строки, стандартные функции работы с ними; массивы и лямбды не надо. - * Функции для печатанья значений переменных в языке. - * Тайпчекер на случай, чтобы отфильтровывать бредовые программы. - * [new методы](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/new-modifier) - * Я слышал, что при их использовании вместе с интерфейсами, там возникает какая-то нетривиальная семантика. Надо будет разобраться. [Вот](https://gist.github.com/Kakadu/331354abae0269e6495bbb0af416853c) пример. -
-1. C# с исключениями
Подробнее - * С# - * Int, string, bool (без array, double) - * тип `var` по желанию (если не считаете C# *** языком) - * один класс в котором Main, другие методы и поля. Рекурсия, стандартные конструкции, присваивание. - * Анонимные лямбды не надо. - * `ovarride/virtual` не надо (бессмысленно) - * Без вложенных классов и методов - * Синтаксис задания исключений. Наследование рудиментарное, только для исключений на 2 уровня глубины - * Try/Catch/finally, фильтры исключений - * API для открытия и записи в файл, чтобы можно было проверить, что в finally файл действительно закрывается. -
-1. С# с [мультиметодами](https://en.wikipedia.org/wiki/Multiple_dispatch#C#)
Подробнее - * По сслыке есть пример из Вики, который показывает их в действии. - * Поддержать нужно в языке как минимум всё то, что нужно для этого примера - * присваивание надо, функции как first class citizens -- нет. -
-1. Python
Подробнее - * Cтандартные конструкции: циклы, ветвления, прочие - * Стандартные типы: числа, строки, списки - * Функции, анонимные функции, рекурсия и т.п. - * Интерполяция строк - * Классы и методы. [Динамическое дополнение методов](https://block.arch.ethz.ch/blog/2016/07/adding-methods-to-python-classes) - * Учитывать отступы и отсутствие отступов тоже надо - ```python - >>> { - ... "this": True, - ... "that": False, - ... "them": [1, 2, - ... 3, 4, 5, - ... 6, 7, 8, - ... 9, 10, 11, 23] - ... } - {'this': True, 'that': False, 'them': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 23]} - ``` -
-1. Ruby (все фичи, что есть в Питоне, но Руби) -1. [Menhir](http://gallium.inria.fr/~fpottier/menhir/manual.pdf) + рекурсивный спуск
Подробнее - * Такой своеобразный DSL для написания парсеров. По умолчанию он парсит LR-способом (вам не обязательно знать, что это такое) - * без action кода, ассоциативность и приоритеты нужны - * устранение левой рекурсии -
-1. Go
Подробнее - * Стандартные типы данных (int, bool, string, char) - * Функции (обычные, рекурсивные, first-class, замыкания (в том числе с поддержкой присваивания)) - * Циклы, условный оператор (if) - * Массивы и присваивание можно не делать - * Прочее - * ключевые слова: break func if else continue for return var - * предопределенные идентификаторы: bool int string true false nil len panic print println recover -
-1. Prolog/Datalog [Solving murder with prolog](https://xmonader.github.io/prolog/2018/12/21/solving-murder-prolog.html) -1. [Cypher](https://neo4j.com/developer/cypher)
Подробнее - * мини-язык для доступа к графовым базам данных - * простой парсер, простой интепретатор, который исполняет запросы на конкретных графах - * Пример возьмите [отсюда](https://neo4j.com/docs/cypher-manual/current/clauses/match/) и [отсюда](https://neo4j.com/docs/cypher-manual/5/clauses/where/), их там много - * Использовать свой тип данных для представления графов **запрещено**. Возьмите какую-нибудь библиотеку. -
-1. Производительный SQL
Подробнее - * Минимальный язык запросов к базам данных: SELECT, JOIN WHERE и может что-то ещё - * Интерпретатор запросов на этом языке - * Эти запросы должны исполняться на больших данных, автогенеренных с помощью https://github.com/NetApp/SQL_Storage_Benchmark. Постарайтесь не складывать большие файлы в Git, а придумать, чтобы они докачивались при билде. - * Большие входы должны заставить интерпретатор исполняться запросы эффективно, а не как попало. -
-1. [LLVM IR](https://llvm.org/docs/LangRef.html)
Подробнее - * Типы: - * int'ы разной битности (i1 - int из одного бита = bool) - * half, float, double - * указатели - * вектора, массивы, структуры - * функции - * токены, метки - * [Весь набор инструкций](https://llvm.org/docs/LangRef.html#instruction-reference) - * [High level structure](https://llvm.org/docs/LangRef.html#high-level-structure) реализовывать не нужно, но нужно уметь их отбрасывать, чтобы можно было запускать программы включающие их -
- -### Гробики - -40. OCaml + GADT (2 человека, т.к. напоминает гроб)
Подробнее - * Всё, что есть в задаче OCaml+ADT - * OCaml где алгебраические типы заменены на обобщенные (generalized) алгебраические типы - * Интерпретатор точно будет такой же, как в задаче про обычные алгебраические типы - * Вывод/проверка типов (сильно) сложнее, чем для обычных алгебраических, поэтому два человека - * Нужно поддержать явные аннотации типов, потому что автоматический вывод типов не могёт - * Типовые переменные могут убегать из области видимости и т.д. - * [Умная сслыка, описывающая что примерно вас ждет](https://ocaml.org/releases/4.12/manual/gadts.html) -
-40. -40. [OchaCaml](http://pllab.is.ocha.ac.jp/~asai/OchaCaml) (Caml Light + delim/cc) (2 человека, т.к. напоминает гроб)
Подробнее - * стандартные типы (числа, списки), - * функции обычные и анонимные, замыкания и рекурсия - * конструкции для отладочной печати - * delim/сс - * полиморфные типы для всего этого - * типизация там необычная, надо по одной ссылке долистать до описания того, как это типизировать; по другой ссылке долистать до способов написания интерпретатора/компиляции - * По сути эта задача и две предыдущие про */сс -- суть одно и то же -
-1. - - - -##### Прочие замечания - -Некоторые темы записаны на двоих. Это означает, что делаете в двоем, вместе, одно и то же. В конце я буду ожидать, что оба разбираются в коде и смогут объяснить, что там происходит. - -Если у Вас есть предложения по добавлению других языков -- пишите.