-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kakadu <[email protected]>
- Loading branch information
Showing
25 changed files
with
187 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_build | ||
_coverage | ||
/_esy | ||
/node_modules | ||
/esy.lock | ||
/.melange.eobjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
profile=janestreet | ||
sequence-style=terminator | ||
max-indent=2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 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} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let rec nonwrapped_fac n = if n <= 1 then 1 else n * nonwrapped_fac (n - 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(* If we don't create .mli, the linter will not warn about this factorial. | ||
Don't know yet, is it good or bad *) | ||
val nonwrapped_fac : int -> int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is a homework for functional programming course. | ||
|
||
Author: [Julia Kononova](https://github.com/juliakononov) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(env | ||
(dev | ||
(flags | ||
(:standard -warn-error -A -w -3-9-32-34-58 -w -37-69))) | ||
(release | ||
(flags | ||
(:standard -warn-error -A -w -58)))) | ||
|
||
(library | ||
(name nonwrapped_lib) | ||
(modules Nonwrapped) | ||
(wrapped false)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(lang dune 3.7) | ||
|
||
(cram enable) | ||
|
||
(license LGPL-3.0-or-later) | ||
|
||
(package | ||
(name CSharpOOP) ; FIXME and regenerate .opam file using 'dune build @install' | ||
(allow_empty) | ||
(synopsis "xxx") | ||
(description "xxx") | ||
(version 0.1) | ||
(depends | ||
dune | ||
angstrom | ||
(ppx_inline_test :with-test) | ||
ppx_expect | ||
ppx_deriving)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type statement = Return of int option [@@deriving show { with_path = false }] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(library | ||
(name wrapped_lib) | ||
(modules Ast Parser) | ||
(wrapped true) | ||
(libraries angstrom) | ||
(preprocess | ||
(pps ppx_deriving.show))) | ||
|
||
(library | ||
(name tests) | ||
(modules p_tests) | ||
(libraries wrapped_lib nonwrapped_lib) | ||
(inline_tests) | ||
(preprocess | ||
(pps ppx_expect ppx_inline_test))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
open Wrapped_lib.Parser | ||
open Wrapped_lib.Ast | ||
|
||
(* PARSERS *) | ||
let show_wrap form = function | ||
| Some x -> form Format.std_formatter x | ||
| _ -> print_endline "Parsing error" | ||
;; | ||
|
||
let print_pars ps pp str = show_wrap pp (parse_to_some ps str) | ||
|
||
(* statements tests*) | ||
|
||
let test_decl = print_pars s_declaration pp_statement | ||
|
||
let%expect_test _ = | ||
print_endline "Hello, world!"; | ||
[%expect "Hello, world!"] | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(** Copyright 2023-2024, Julia Kononova *) | ||
|
||
(** SPDX-License-Identifier: LGPL-3.0-or-later *) | ||
|
||
(* val show_wrap : (Format.formatter -> 'a -> unit) -> 'a option -> unit | ||
val print_pars : 'a Angstrom.t -> (Format.formatter -> 'a -> unit) -> string -> unit *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let parse_to_some p str = | ||
match Angstrom.parse_string p ~consume:Angstrom.Consume.All str with | ||
| Ok x -> Some x | ||
| Error _ -> None | ||
;; | ||
|
||
let s_declaration = Angstrom.return (Ast.Return None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
val parse_to_some : 'a Angstrom.t -> string -> 'a option | ||
val s_declaration : Ast.statement Angstrom.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$ dune build | ||
$ dune test | ||
$ dune describe | ||
|
||
$ zanuda -unused-decls . |grep -v "Base\|Angstrom\|Ppx_deriving_runtime" | ||
Unused declarations: | ||
0: Nonwrapped.nonwrapped_fac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
let first = let open Simple in meow;; | ||
let second = let open Simple in Meow.InnerMeow.inner;; | ||
|
||
let%test _ = Simple.is_space ' ' | ||
(* let%expect_test _ = | ||
Printf.printf "%b\n" (Simple.is_space ' '); | ||
[%expect "true"] *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
let meow = 1;; | ||
|
||
module Meow = struct | ||
module InnerMeow = struct | ||
let inner = 7 | ||
module InnerMeow = struct | ||
let inner = 7 | ||
end | ||
let woof = 3 | ||
let meow = 11 | ||
end | ||
|
||
let _false_use = Meow.woof | ||
|
||
|
||
let is_space = function ' '| '\n' -> true | _ -> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
module Meow : sig | ||
module InnerMeow : sig | ||
module InnerMeow : sig | ||
val inner : int | ||
end | ||
val woof : int | ||
val meow : int | ||
end | ||
|
||
val meow : int | ||
val is_space : char -> bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let () = print_int (Custom_lib.Custom_lib_impl.incr 41) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let incr n = n+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
val incr : int -> int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
(library | ||
(name test_Simple) | ||
(wrapped false) | ||
(modules | ||
Simple | ||
SecondTU | ||
) | ||
; (flags | ||
; (:standard -dtypedtree)) | ||
(instrumentation | ||
(backend bisect_ppx))) | ||
(modules | ||
Simple | ||
SecondTU | ||
; | ||
) | ||
(inline_tests) | ||
(preprocess | ||
(pps ppx_expect ppx_inline_test))) | ||
|
||
(library | ||
(name custom_lib) | ||
(public_name Simple.Custom) | ||
;(package Simple) | ||
(modules custom_lib_impl)) | ||
|
||
(executable | ||
(name custom_demo) | ||
(modules custom_demo) | ||
(libraries custom_lib)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
(lang dune 2.8) | ||
|
||
(cram enable) | ||
|
||
(package | ||
(name Simple)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
$ dune build | ||
$ zanuda -unused-decls . | ||
unused decl: Simple.Meow.meow | ||
unused decl: Simple.Meow.woof | ||
$ dune build @check | ||
$ dune describe | ||
$ zanuda -unused-decls . | ||
module "Custom_lib" is omitted | ||
Unused declarations: | ||
0: Custom_lib_impl.incr | ||
1: Simple.Meow.meow | ||
2: Simple.Meow.woof | ||
# Custom_lib_impl.incr is not found because a custom public name for library 'custom_lib' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(cram | ||
(deps %{bin:zanuda})) |