From 84ad9c32a217f9a283854828c5f4379369c0d900 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 3 Nov 2020 05:25:44 +0900 Subject: [PATCH 1/5] Fix test and benchmark Signed-off-by: Sora Morimoto --- benchmarks/pure_benchmark.ml | 8 ++++---- lib_test/test_json.ml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/pure_benchmark.ml b/benchmarks/pure_benchmark.ml index 295e6f2..226d13e 100644 --- a/benchmarks/pure_benchmark.ml +++ b/benchmarks/pure_benchmark.ml @@ -21,7 +21,7 @@ let zero = let make_bench name parser contents = Bench.Test.create ~name (fun () -> - match Angstrom.(parse_bigstring parser contents) with + match Angstrom.(parse_bigstring ~consume:All parser contents) with | Ok _ -> () | Error err -> failwith err) ;; @@ -58,10 +58,10 @@ let main () = ] in let http = - Bench.make_command [ make_http "http" http_get ] + Bench.make_command [ make_http "http" http_get ] in let numbers = - Bench.make_command [ + Bench.make_command [ Bench.Test.create ~name:"float" (fun () -> float_of_string "1.7242915150166418e+36"); Bench.Test.create ~name:"int" (fun () -> @@ -111,7 +111,7 @@ let main () = ] in Command.run - (Command.group ~summary:"various angstrom benchmarks" + (Command.group ~summary:"various angstrom benchmarks" [ "json" , json ; "endian" , endian ; "http" , http diff --git a/lib_test/test_json.ml b/lib_test/test_json.ml index 98b8a8c..306ad2b 100644 --- a/lib_test/test_json.ml +++ b/lib_test/test_json.ml @@ -14,6 +14,6 @@ let read f = let () = let twitter_big = read Sys.argv.(1) in - match Angstrom.(parse_bigstring RFC7159.json twitter_big) with + match Angstrom.(parse_bigstring ~consume:All RFC7159.json twitter_big ) with | Ok _ -> () | Error err -> failwith err From 24237b4a66d9b359bb2db8a071ad58227c296612 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 3 Nov 2020 05:33:15 +0900 Subject: [PATCH 2/5] Update .gitignore Signed-off-by: Sora Morimoto --- .gitignore | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 098c481..da33021 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,6 @@ -.*.sw[a-z] -*~ _build/ -_tests/ -lib_test/tests_ -setup.log -setup.data -*.native -*.byte -*.docdir +_opam/ +.vscode/ +.merlin *.install -.merlin \ No newline at end of file +*.log From dad09e9c8e0a940f8264f6a930ea38446f9a4f0b Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 3 Nov 2020 05:48:43 +0900 Subject: [PATCH 3/5] Update to dune 2.0 Signed-off-by: Sora Morimoto --- META.angstrom.template | 16 ---------- angstrom-async.opam | 37 ++++++++++++++-------- angstrom-lwt-unix.opam | 37 ++++++++++++++-------- angstrom-unix.opam | 35 ++++++++++++++------- angstrom.opam | 54 +++++++++++++++++++------------- dune-project | 71 +++++++++++++++++++++++++++++++++++++++++- examples/dune | 1 + lib_test/dune | 11 ++++--- 8 files changed, 181 insertions(+), 81 deletions(-) delete mode 100644 META.angstrom.template diff --git a/META.angstrom.template b/META.angstrom.template deleted file mode 100644 index e8f92b9..0000000 --- a/META.angstrom.template +++ /dev/null @@ -1,16 +0,0 @@ -# JBUILDER_GEN - -package "unix" ( - description = "Deprecated. Use angstrom-unix directly" - requires = "angstrom-unix" -) - -package "lwt-unix" ( - description = "Deprecated. Use angstrom-lwt-unix directly" - requires = "angstrom-lwt-unix" -) - -package "async" ( - description = "Deprecated. Use angstrom-async directly" - requires = "angstrom-async" -) \ No newline at end of file diff --git a/angstrom-async.opam b/angstrom-async.opam index 22460af..5331789 100644 --- a/angstrom-async.opam +++ b/angstrom-async.opam @@ -1,19 +1,30 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -maintainer: "Spiros Eliopoulos " -authors: [ "Spiros Eliopoulos " ] -license: "BSD-3-clause" +synopsis: "Async support for Angstrom" +maintainer: ["Spiros Eliopoulos "] +authors: ["Spiros Eliopoulos "] +license: "BSD-3-Clause" homepage: "https://github.com/inhabitedtype/angstrom" bug-reports: "https://github.com/inhabitedtype/angstrom/issues" -dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" +depends: [ + "dune" {>= "2.0"} + "ocaml" {>= "4.04"} + "odoc" {with-doc} + "angstrom" + "async" +] build: [ ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] ] -depends: [ - "ocaml" {>= "4.04.1"} - "dune" {>= "1.8"} - "angstrom" {>= "0.7.0"} - "async" {>= "v0.10.0"} -] -synopsis: "Async support for Angstrom" +dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" diff --git a/angstrom-lwt-unix.opam b/angstrom-lwt-unix.opam index b956947..9260e44 100644 --- a/angstrom-lwt-unix.opam +++ b/angstrom-lwt-unix.opam @@ -1,20 +1,31 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -maintainer: "Spiros Eliopoulos " -authors: [ "Spiros Eliopoulos " ] -license: "BSD-3-clause" +synopsis: "Lwt_unix support for Angstrom" +maintainer: ["Spiros Eliopoulos "] +authors: ["Spiros Eliopoulos "] +license: "BSD-3-Clause" homepage: "https://github.com/inhabitedtype/angstrom" bug-reports: "https://github.com/inhabitedtype/angstrom/issues" -dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" -build: [ - ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] depends: [ - "ocaml" {>= "4.03.0"} - "dune" {>= "1.8"} + "dune" {>= "2.0"} + "ocaml" {>= "4.04"} + "odoc" {with-doc} "angstrom" - "lwt" "base-unix" + "lwt" ] -synopsis: "Lwt_unix support for Angstrom" +build: [ + ["dune" "subst"] {pinned} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" diff --git a/angstrom-unix.opam b/angstrom-unix.opam index 3ae9b22..15b6848 100644 --- a/angstrom-unix.opam +++ b/angstrom-unix.opam @@ -1,19 +1,30 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -maintainer: "Spiros Eliopoulos " -authors: [ "Spiros Eliopoulos " ] -license: "BSD-3-clause" +synopsis: "Unix support for Angstrom" +maintainer: ["Spiros Eliopoulos "] +authors: ["Spiros Eliopoulos "] +license: "BSD-3-Clause" homepage: "https://github.com/inhabitedtype/angstrom" bug-reports: "https://github.com/inhabitedtype/angstrom/issues" -dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" -build: [ - ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] depends: [ - "ocaml" {>= "4.03.0"} - "dune" {>= "1.8"} + "dune" {>= "2.0"} + "ocaml" {>= "4.04"} + "odoc" {with-doc} "angstrom" "base-unix" ] -synopsis: "Unix support for Angstrom" +build: [ + ["dune" "subst"] {pinned} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" diff --git a/angstrom.opam b/angstrom.opam index 721a437..2fcd8b1 100644 --- a/angstrom.opam +++ b/angstrom.opam @@ -1,24 +1,5 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -maintainer: "Spiros Eliopoulos " -authors: [ "Spiros Eliopoulos " ] -license: "BSD-3-clause" -homepage: "https://github.com/inhabitedtype/angstrom" -bug-reports: "https://github.com/inhabitedtype/angstrom/issues" -dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" -build: [ - ["dune" "subst"] {pinned} - ["dune" "build" "-p" name "-j" jobs] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} -] -depends: [ - "ocaml" {>= "4.04.0"} - "dune" {>= "1.8"} - "alcotest" {with-test & >= "0.8.1"} - "bigstringaf" - "result" - "ppx_let" {with-test & >= "0.14.0"} - "ocaml-syntax-shims" {build} -] synopsis: "Parser combinators built for speed and memory-efficiency" description: """ Angstrom is a parser-combinator library that makes it easy to write efficient, @@ -27,4 +8,35 @@ exposes monadic and applicative interfaces for composition, and supports incremental input through buffered and unbuffered interfaces. Both interfaces give the user total control over the blocking behavior of their application, with the unbuffered interface enabling zero-copy IO. Parsers are backtracking by -default and support unbounded lookahead.""" +default and support unbounded lookahead. +""" +maintainer: ["Spiros Eliopoulos "] +authors: ["Spiros Eliopoulos "] +license: "BSD-3-Clause" +homepage: "https://github.com/inhabitedtype/angstrom" +bug-reports: "https://github.com/inhabitedtype/angstrom/issues" +depends: [ + "dune" {>= "2.0"} + "alcotest" {with-test & >= "0.8.1"} + "ocaml" {>= "4.04"} + "ocaml-syntax-shims" {build} + "odoc" {with-doc} + "ppx_let" {with-test & >= "0.14"} + "bigstringaf" + "result" +] +build: [ + ["dune" "subst"] {pinned} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/inhabitedtype/angstrom.git" diff --git a/dune-project b/dune-project index 5bfddd0..182ef37 100644 --- a/dune-project +++ b/dune-project @@ -1,2 +1,71 @@ -(lang dune 1.8) +(lang dune 2.0) (name angstrom) + +(license BSD-3-Clause) +(authors "Spiros Eliopoulos ") +(maintainers "Spiros Eliopoulos ") +(source + (github inhabitedtype/angstrom)) +(bug_reports "https://github.com/inhabitedtype/angstrom/issues") +(homepage "https://github.com/inhabitedtype/angstrom") + +(generate_opam_files true) + +(package + (name angstrom) + (synopsis "Parser combinators built for speed and memory-efficiency") + (description "\ +Angstrom is a parser-combinator library that makes it easy to write efficient, +expressive, and reusable parsers suitable for high-performance applications. It +exposes monadic and applicative interfaces for composition, and supports +incremental input through buffered and unbuffered interfaces. Both interfaces +give the user total control over the blocking behavior of their application, +with the unbuffered interface enabling zero-copy IO. Parsers are backtracking by +default and support unbounded lookahead. +") + (depends + (alcotest + (and + :with-test + (>= 0.8.1))) + (ocaml + (>= 4.04)) + (ocaml-syntax-shims :build) + (odoc :with-doc) + (ppx_let + (and + :with-test + (>= 0.14))) + bigstringaf + result)) + +(package + (name angstrom-async) + (synopsis "Async support for Angstrom") + (depends + (ocaml + (>= 4.04)) + (odoc :with-doc) + angstrom + async)) + +(package + (name angstrom-lwt-unix) + (synopsis "Lwt_unix support for Angstrom") + (depends + (ocaml + (>= 4.04)) + (odoc :with-doc) + angstrom + base-unix + lwt)) + +(package + (name angstrom-unix) + (synopsis "Unix support for Angstrom") + (depends + (ocaml + (>= 4.04)) + (odoc :with-doc) + angstrom + base-unix)) diff --git a/examples/dune b/examples/dune index 0fd2e29..7b8f173 100644 --- a/examples/dune +++ b/examples/dune @@ -11,6 +11,7 @@ (libraries angstrom)) ;; Build bytecode library just to make sure this compiles + (alias (name examples) (deps RFC7159.cma RFC2616.cma)) diff --git a/lib_test/dune b/lib_test/dune index 6e00fe3..c94d1d9 100644 --- a/lib_test/dune +++ b/lib_test/dune @@ -6,7 +6,8 @@ (preprocess (per_module (future_syntax test_let_syntax_native) - ((pps ppx_let) test_let_syntax_ppx)))) + ((pps ppx_let) + test_let_syntax_ppx)))) (executables (libraries alcotest angstrom angstrom_test) @@ -18,10 +19,10 @@ (modules test_json) (names test_json)) -(alias - (name runtest) - (package angstrom) +(rule + (alias runtest) + (mode promote) (deps (:< test_angstrom.exe)) (action - (run %{<}))) \ No newline at end of file + (run %{<}))) From 6072cbcebb01a6f2d243df0c415ff68d844732db Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 3 Nov 2020 05:53:19 +0900 Subject: [PATCH 4/5] Update .gitignore Signed-off-by: Sora Morimoto --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index da33021..15cf749 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ _build/ _opam/ .vscode/ .merlin -*.install -*.log From f533cbc9b30273cf8b79bd8c08d2e873163ec418 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 3 Nov 2020 05:53:40 +0900 Subject: [PATCH 5/5] Simplify Makefile Signed-off-by: Sora Morimoto --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 699eaa3..a3d12bc 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,4 @@ doc: dune build @doc clean: - rm -rf _build *.install + dune clean