mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Sync
This commit is contained in:
parent
691c84f1c8
commit
a5dbf5156a
1 changed files with 9 additions and 2 deletions
11
src/SM.ml
11
src/SM.ml
|
|
@ -95,7 +95,7 @@ let rec eval env ((cstack, stack, ((st, i, o) as c)) as conf) = function
|
||||||
Takes a program, an input stream, and returns an output stream this program calculates
|
Takes a program, an input stream, and returns an output stream this program calculates
|
||||||
*)
|
*)
|
||||||
let run p i =
|
let run p i =
|
||||||
(*print_prg p;*)
|
print_prg p;
|
||||||
let module M = Map.Make (String) in
|
let module M = Map.Make (String) in
|
||||||
let rec make_map m = function
|
let rec make_map m = function
|
||||||
| [] -> m
|
| [] -> m
|
||||||
|
|
@ -153,7 +153,14 @@ let compile (defs, p) =
|
||||||
| Stmt.Pattern.Ident n -> [SWAP]
|
| Stmt.Pattern.Ident n -> [SWAP]
|
||||||
| Stmt.Pattern.Wildcard -> [DROP]
|
| Stmt.Pattern.Wildcard -> [DROP]
|
||||||
| Stmt.Pattern.Sexp (_, ps) ->
|
| Stmt.Pattern.Sexp (_, ps) ->
|
||||||
(List.flatten @@ List.mapi (fun i p -> [DUP; CONST i; CALL (".elem", 2, false)] @ inner p) ps) @
|
(List.flatten @@
|
||||||
|
List.mapi
|
||||||
|
(fun i p ->
|
||||||
|
[DUP; CONST i; CALL (".elem", 2, false)] @
|
||||||
|
inner p
|
||||||
|
)
|
||||||
|
ps
|
||||||
|
) @
|
||||||
[DROP]
|
[DROP]
|
||||||
in
|
in
|
||||||
inner p @ [ENTER (Stmt.Pattern.vars p)]
|
inner p @ [ENTER (Stmt.Pattern.vars p)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue