diff --git a/Lama.opam b/Lama.opam index b93693826..b3d39c380 100644 --- a/Lama.opam +++ b/Lama.opam @@ -1,32 +1,24 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "1.30" - -synopsis: "Lama programming language" -maintainer: "dboulytchev@gmail.com" -authors: [ - "Dmitry Boulytchev " - "Daniil Berezun " - "Egor Sheremetov " -] -homepage: "https://github.com/PLTools/Lama" -bug-reports: "https://github.com/PLTools/Lama/issues" - +synopsis: "TODO" depends: [ - "ocaml" { >= "4.13.1" } - "ocamlfind" { build } - "camlp5" { >= "8.00.05" } - "ostap" { >= "0.5"} - "GT" { >= "0.5.1" } - "posix-uname" { = "2.0.2" } + "dune" {>= "3.3"} + "posix-uname" + "GT" + "ostap" {>= "0.6"} + "odoc" {with-doc} ] - build: [ - [make] - [make "regression"] {with-test} + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] ] -install: [make "install"] - -dev-repo: "git+https://github.com/PLTools/Lama.git" -url { - src: "git+https://github.com/PLTools/Lama.git#1.30" -} diff --git a/dune-project b/dune-project index c45c2d060..a6817af70 100644 --- a/dune-project +++ b/dune-project @@ -6,5 +6,10 @@ (package (name Lama) + (allow_empty) (synopsis "TODO") - (depends posix-uname)) + (depends + posix-uname + GT + (ostap + (>= 0.6)))) diff --git a/tutorial/.gitignore b/tutorial/.gitignore deleted file mode 120000 index 65f1cfa74..000000000 --- a/tutorial/.gitignore +++ /dev/null @@ -1 +0,0 @@ -../stdlib/.gitignore \ No newline at end of file diff --git a/tutorial/.gitignore b/tutorial/.gitignore new file mode 100644 index 000000000..2c692a61d --- /dev/null +++ b/tutorial/.gitignore @@ -0,0 +1,9 @@ +*.html +*.sm +/*.log +*.i +*.s +*.exe +*.x32.exe +*.x64.exe + diff --git a/tutorial/Makefile b/tutorial/Makefile deleted file mode 100644 index b669dab81..000000000 --- a/tutorial/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -FILES=$(wildcard *.lama) -ALL=$(sort $(FILES:.lama=)) -EXTRA_TARGETS = - -ifeq ($(LAMAC),) - LAMAC := LAMA=../runtime ../src/lamac -I ../stdlib - EXTRA_TARGETS += ../src/lamac -endif - -all: $(EXTRA_TARGETS) $(ALL) - -../src/lamac: - $(MAKE) -C ../src - -%: %.lama - $(LAMAC) $< - -clean: - $(RM) -R *.s *.o *.i *~ $(ALL) diff --git a/tutorial/dune b/tutorial/dune index 1f6e131c7..1a7ea7bbe 100644 --- a/tutorial/dune +++ b/tutorial/dune @@ -1,6 +1,7 @@ + (rule - (targets Hello.exe) - (deps Hello.lama) + (targets Expressions.x32.exe) + (deps (:lama Expressions.lama) ../runtime32/runtime.a) (mode (promote (until-clean))) (action @@ -9,11 +10,191 @@ "../runtime32" (run %{project_root}/src/Driver.exe - %{deps} -march=x86 + %{lama} -I ../stdlib/x32 -I ../runtime32 -o %{targets})))) + +(rule + (targets Expressions.x64.exe) + (deps (:lama Expressions.lama) ../runtime/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime" + (run + %{project_root}/src/Driver.exe + -march=x86_64 + %{lama} + -I + ../stdlib/x64 + -I + ../runtime + -o + %{targets})))) + +(rule + (targets Functions.x32.exe) + (deps (:lama Functions.lama) ../runtime32/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime32" + (run + %{project_root}/src/Driver.exe + -march=x86 + %{lama} + -I + ../stdlib/x32 + -I + ../runtime32 + -o + %{targets})))) + +(rule + (targets Functions.x64.exe) + (deps (:lama Functions.lama) ../runtime/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime" + (run + %{project_root}/src/Driver.exe + -march=x86_64 + %{lama} + -I + ../stdlib/x64 + -I + ../runtime + -o + %{targets})))) + +(rule + (targets Hello.x32.exe) + (deps (:lama Hello.lama) ../runtime32/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime32" + (run + %{project_root}/src/Driver.exe + -march=x86 + %{lama} + -I + ../stdlib/x32 + -I + ../runtime32 + -o + %{targets})))) + +(rule + (targets Hello.x64.exe) + (deps (:lama Hello.lama) ../runtime/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime" + (run + %{project_root}/src/Driver.exe + -march=x86_64 + %{lama} + -I + ../stdlib/x64 + -I + ../runtime + -o + %{targets})))) + +(rule + (targets PatternMatching.x32.exe) + (deps (:lama PatternMatching.lama) ../runtime32/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime32" + (run + %{project_root}/src/Driver.exe + -march=x86 + %{lama} + -I + ../stdlib/x32 + -I + ../runtime32 + -o + %{targets})))) + +(rule + (targets PatternMatching.x64.exe) + (deps (:lama PatternMatching.lama) ../runtime/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime" + (run + %{project_root}/src/Driver.exe + -march=x86_64 + %{lama} + -I + ../stdlib/x64 + -I + ../runtime + -o + %{targets})))) + +(rule + (targets Values.x32.exe) + (deps (:lama Values.lama) ../runtime32/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime32" + (run + %{project_root}/src/Driver.exe + -march=x86 + %{lama} + -I + ../stdlib/x32 + -I + ../runtime32 + -o + %{targets})))) + +(rule + (targets Values.x64.exe) + (deps (:lama Values.lama) ../runtime/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "../runtime" + (run + %{project_root}/src/Driver.exe + -march=x86_64 + %{lama} + -I + ../stdlib/x64 + -I + ../runtime + -o + %{targets})))) diff --git a/tutorial/gen.ml b/tutorial/gen.ml new file mode 100644 index 000000000..90abb451e --- /dev/null +++ b/tutorial/gen.ml @@ -0,0 +1,44 @@ +#use "topfind";; +#require "str";; +let demos = ["Expressions"; "Functions"; "Hello"; "PatternMatching"; "Values"] + +let template = {| +(rule + (targets %DEMO%.exe) + (deps (:lama %DEMOSRC%.lama) %RUNTIME%/runtime.a) + (mode + (promote (until-clean))) + (action + (setenv + LAMA + "%RUNTIME%" + (run + %{project_root}/src/Driver.exe + %EXTRASWITCHES% + %{lama} + -I + %STDLIB% + -I + %RUNTIME% + -o + %{targets})))) +|} + +let () = + Out_channel.with_open_text "dune" (fun ch -> + List.iter (fun demo -> + template + |> Str.global_replace (Str.regexp "%DEMO%") (demo^".x32") + |> Str.global_replace (Str.regexp "%DEMOSRC%") demo + |> Str.global_replace (Str.regexp "%RUNTIME%") "../runtime32" + |> Str.global_replace (Str.regexp "%STDLIB%") "../stdlib/x32" + |> Str.global_replace (Str.regexp "%EXTRASWITCHES%") "-march=x86" + |> output_string ch; + template + |> Str.global_replace (Str.regexp "%DEMO%") (demo^".x64") + |> Str.global_replace (Str.regexp "%DEMOSRC%") demo + |> Str.global_replace (Str.regexp "%RUNTIME%") "../runtime" + |> Str.global_replace (Str.regexp "%STDLIB%") "../stdlib/x64" + |> Str.global_replace (Str.regexp "%EXTRASWITCHES%") "-march=x86_64" + |> output_string ch; + ) demos)