mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
Dunify tutorial
Signed-off-by: Kakadu <Kakadu@pm.me>
This commit is contained in:
parent
3f7f51b2f0
commit
a91f4824c4
6 changed files with 262 additions and 51 deletions
46
Lama.opam
46
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 <dboulytchev@gmail.com>"
|
||||
"Daniil Berezun <danya.berezun@gmail.com>"
|
||||
"Egor Sheremetov <egor.sheremetov.dev@gmail.com>"
|
||||
]
|
||||
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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,10 @@
|
|||
|
||||
(package
|
||||
(name Lama)
|
||||
(allow_empty)
|
||||
(synopsis "TODO")
|
||||
(depends posix-uname))
|
||||
(depends
|
||||
posix-uname
|
||||
GT
|
||||
(ostap
|
||||
(>= 0.6))))
|
||||
|
|
|
|||
1
tutorial/.gitignore
vendored
1
tutorial/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
../stdlib/.gitignore
|
||||
9
tutorial/.gitignore
vendored
Normal file
9
tutorial/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
*.html
|
||||
*.sm
|
||||
/*.log
|
||||
*.i
|
||||
*.s
|
||||
*.exe
|
||||
*.x32.exe
|
||||
*.x64.exe
|
||||
|
||||
|
|
@ -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)
|
||||
187
tutorial/dune
187
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}))))
|
||||
|
|
|
|||
44
tutorial/gen.ml
Normal file
44
tutorial/gen.ml
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue