aboutsummaryrefslogtreecommitdiff
path: root/discocaml
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-01-17 09:16:47 -0600
committerNathan Ringo <nathan@remexre.com>2024-01-17 09:16:47 -0600
commit1cdb8d8f6c328037b8f1b9446a497e0e94861f19 (patch)
treebcd5273f7438976328431d612f10c6aa839beab3 /discocaml
parent59accae1e5b6848592b0beaa6f0e6c481288d357 (diff)
Start of discocaml.
Diffstat (limited to 'discocaml')
-rw-r--r--discocaml/default.nix10
-rw-r--r--discocaml/dune7
-rw-r--r--discocaml/dune-project6
-rw-r--r--discocaml/main.ml27
4 files changed, 50 insertions, 0 deletions
diff --git a/discocaml/default.nix b/discocaml/default.nix
new file mode 100644
index 0000000..0045cdf
--- /dev/null
+++ b/discocaml/default.nix
@@ -0,0 +1,10 @@
+{ buildDunePackage, ocaml-compiler-libs, ppx_deriving, ppx_import, ppxlib }:
+
+buildDunePackage {
+ pname = "discocaml";
+ version = "0.1.0";
+ minimalOcamlVersion = "5.1";
+ src = ./.;
+ nativeBuildInputs = [ ];
+ buildInputs = [ ppx_deriving ppx_import ppxlib ];
+}
diff --git a/discocaml/dune b/discocaml/dune
new file mode 100644
index 0000000..02fcc09
--- /dev/null
+++ b/discocaml/dune
@@ -0,0 +1,7 @@
+(executable
+ (libraries compiler-libs.common)
+ (name main)
+ (package discocaml)
+ (preprocess
+ (staged_pps ppx_import ppx_deriving.show))
+ (public_name discocaml))
diff --git a/discocaml/dune-project b/discocaml/dune-project
new file mode 100644
index 0000000..bd6504b
--- /dev/null
+++ b/discocaml/dune-project
@@ -0,0 +1,6 @@
+(lang dune 3.8)
+
+(package
+ (name discocaml)
+ (synopsis "Some tools for interacting with OCaml with a Discord bot")
+ (depends))
diff --git a/discocaml/main.ml b/discocaml/main.ml
new file mode 100644
index 0000000..2cc97b5
--- /dev/null
+++ b/discocaml/main.ml
@@ -0,0 +1,27 @@
+(*
+type position = [%import: Lexing.position] [@@deriving show]
+
+type location = [%import: (Location.t[@with Lexing.position := position])]
+[@@deriving show]
+
+type constant = [%import: Parsetree.constant] [@@deriving show]
+type expression_desc = [%import: Parsetree.expression_desc] [@@deriving show]
+type expression = [%import: Parsetree.expression] [@@deriving show]
+
+type structure_item_desc = [%import: Parsetree.structure_item_desc]
+[@@deriving show]
+
+type structure_item = [%import: Parsetree.structure_item] [@@deriving show]
+type structure = [%import: Parsetree.structure] [@@deriving show]
+type toplevel_phrase = [%import: Parsetree.toplevel_phrase] [@@deriving show]
+*)
+
+let parse ~path (src : string) =
+ let buf = Lexing.from_string src in
+ buf.lex_start_p <- { buf.lex_start_p with pos_fname = path };
+ buf.lex_curr_p <- { buf.lex_curr_p with pos_fname = path };
+ Parse.use_file buf
+
+let () =
+ parse ~path:"main.ml" "let () = print_endline ((\"Hello, world!\") )"
+ |> List.iter (Pprintast.toplevel_phrase Format.std_formatter)