Skip to content

Commit 4e5a854

Browse files
basic runtime error handling
1 parent edfbc70 commit 4e5a854

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_mountain"
3-
version = "1.11.76"
3+
version = "1.11.77"
44
authors = ["Andrew <andrew@subarctic.org>"]
55
license = "MIT"
66
description = "Lambda Mountain"

STDLIB/default-rules.lm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ macro ( ('let x y) )
44

55
macro ('match t ps) (tail(
66
(let (uuid term) t)
7-
# (let (uuid matched) ())
8-
9-
# (let (uuid return) ())
10-
(print (uuid term))
11-
# (match-pats( (uuid term) (uuid matched) (uuid return) ps ))
12-
# (uuid return)
7+
(match-pats( (uuid term) ps (fail PatternMatchFailure_s) ))
138
));
9+
10+
macro ('match-pats( term ps remainder )) (
11+
remainder
12+
);
13+
1414
#macro ('match-pats( term matched return () )) ();
1515
#macro ('match-pats( term matched return (ps (lhs rhs)) )) (
1616
# (match-pats( term matched return ps ))

STDLIB/default-stdlib.lm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ print := λ(: x S). (: (tail(
3737
()
3838
)) Nil);
3939

40+
fail := λ(: msg Array<U8,?>). (: (tail(
41+
(print msg)
42+
(exit 1u64)
43+
)) Nil);
44+
45+
exit := λ(: code U64). (: (tail(
46+
(mov( 60u64 RAX ))
47+
(mov( code RDI ))
48+
(syscall())
49+
)) Nil);
50+
4051
print := λ(: x Array<U8,?>). (: (tail(
4152
(mov( x R15 ))
4253
(mov( 0u64 RDX )) # data length

0 commit comments

Comments
 (0)