mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-07 15:28:49 +00:00
Sync
This commit is contained in:
parent
dd5956d663
commit
25eff5c282
3 changed files with 7 additions and 5 deletions
|
|
@ -14,5 +14,6 @@ for i:=0, i<x.length, i:=i+1 do
|
||||||
x[i] := x[i]+2
|
x[i] := x[i]+2
|
||||||
od;
|
od;
|
||||||
|
|
||||||
printString (x)
|
printString (x);
|
||||||
|
|
||||||
|
printString (strcat ("abc", "def"))
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,10 @@ module Builtin =
|
||||||
)
|
)
|
||||||
| "$length" -> (st, i, o, Some (Value.of_int (match List.hd args with Value.Array a -> List.length a | Value.String s -> String.length s)))
|
| "$length" -> (st, i, o, Some (Value.of_int (match List.hd args with Value.Array a -> List.length a | Value.String s -> String.length s)))
|
||||||
| "$array" -> (st, i, o, Some (Value.of_array args))
|
| "$array" -> (st, i, o, Some (Value.of_array args))
|
||||||
| s -> failwith (Printf.sprintf "Wow: %s\n" s)
|
| "strcat" -> let [x; y] = args in
|
||||||
|
(st, i, o, Some (Value.of_string @@ Value.to_string x ^ Value.to_string y))
|
||||||
|
| "isArray" -> let [a] = args in
|
||||||
|
(st, i, o, Some (Value.of_int @@ match a with Array _ -> 1 | _ -> 0))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ open Language
|
||||||
(* binary operator *) | BINOP of string
|
(* binary operator *) | BINOP of string
|
||||||
(* put a constant on the stack *) | CONST of int
|
(* put a constant on the stack *) | CONST of int
|
||||||
(* put a string on the stack *) | STRING of string
|
(* put a string on the stack *) | STRING of string
|
||||||
(* read to stack *) | READ
|
|
||||||
(* write from stack *) | WRITE
|
|
||||||
(* load a variable to the stack *) | LD of string
|
(* load a variable to the stack *) | LD of string
|
||||||
(* store a variable from the stack *) | ST of string
|
(* store a variable from the stack *) | ST of string
|
||||||
(* store in an array *) | STA of string * int
|
(* store in an array *) | STA of string * int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue