Skip to content

Commit 5c2fdfc

Browse files
committed
Closes #32.
1 parent 4036062 commit 5c2fdfc

File tree

5 files changed

+94
-2
lines changed

5 files changed

+94
-2
lines changed

editor/scripts/ki.sjs

+31
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ macro _x {
6666
}
6767
}
6868

69+
macro _throw {
70+
case { $ctx + } => {
71+
throwSyntaxError('Unexpected token +','(+ ...) unsupported, use (add ...) instead',#{$ctx})
72+
}
73+
case { $ctx - } => {
74+
throwSyntaxError('Unexpected token -','(- ...) unsupported, use (sub ...) instead',#{$ctx})
75+
}
76+
case { $ctx * } => {
77+
throwSyntaxError('Unexpected token *','(* ...) unsupported, use (mul ...) instead',#{$ctx})
78+
}
79+
//case { $ctx / } => {
80+
// throwSyntaxError('Unexpected token /','(/ ...) unsupported, use (div ...) instead',#{$ctx})
81+
//}
82+
}
83+
6984
macro _ns {
7085
case { _ $ns $sexprs ... } => {
7186
var nsname = unwrapSyntax(#{$ns});
@@ -572,6 +587,22 @@ macro _sexpr {
572587
throw(_sexpr $x);
573588
}.call(this))
574589
}
590+
591+
rule { (+ $args ...) } => {
592+
_throw +
593+
}
594+
595+
rule { (- $args ...) } => {
596+
_throw -
597+
}
598+
599+
rule { (* $args ...) } => {
600+
_throw *
601+
}
602+
603+
//rule { (/ $args ...) } => {
604+
// _throw /
605+
//}
575606

576607
rule { ($[.] $fn $obj $args ...) } => {
577608
_sexpr $obj . $fn (_args ($args ...))

macros/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ macro _x {
6666
}
6767
}
6868

69+
macro _throw {
70+
case { $ctx + } => {
71+
throwSyntaxError('Unexpected token +','(+ ...) unsupported, use (add ...) instead',#{$ctx})
72+
}
73+
case { $ctx - } => {
74+
throwSyntaxError('Unexpected token -','(- ...) unsupported, use (sub ...) instead',#{$ctx})
75+
}
76+
case { $ctx * } => {
77+
throwSyntaxError('Unexpected token *','(* ...) unsupported, use (mul ...) instead',#{$ctx})
78+
}
79+
//case { $ctx / } => {
80+
// throwSyntaxError('Unexpected token /','(/ ...) unsupported, use (div ...) instead',#{$ctx})
81+
//}
82+
}
83+
6984
macro _ns {
7085
case { _ $ns $sexprs ... } => {
7186
var nsname = unwrapSyntax(#{$ns});
@@ -572,6 +587,22 @@ macro _sexpr {
572587
throw(_sexpr $x);
573588
}.call(this))
574589
}
590+
591+
rule { (+ $args ...) } => {
592+
_throw +
593+
}
594+
595+
rule { (- $args ...) } => {
596+
_throw -
597+
}
598+
599+
rule { (* $args ...) } => {
600+
_throw *
601+
}
602+
603+
//rule { (/ $args ...) } => {
604+
// _throw /
605+
//}
575606

576607
rule { ($[.] $fn $obj $args ...) } => {
577608
_sexpr $obj . $fn (_args ($args ...))

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ki",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "lisp + mori, sweet.js",
55
"repository": {
66
"type": "git",

src/ki.sjs

+31
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ macro _x {
6666
}
6767
}
6868

69+
macro _throw {
70+
case { $ctx + } => {
71+
throwSyntaxError('Unexpected token +','(+ ...) unsupported, use (add ...) instead',#{$ctx})
72+
}
73+
case { $ctx - } => {
74+
throwSyntaxError('Unexpected token -','(- ...) unsupported, use (sub ...) instead',#{$ctx})
75+
}
76+
case { $ctx * } => {
77+
throwSyntaxError('Unexpected token *','(* ...) unsupported, use (mul ...) instead',#{$ctx})
78+
}
79+
//case { $ctx / } => {
80+
// throwSyntaxError('Unexpected token /','(/ ...) unsupported, use (div ...) instead',#{$ctx})
81+
//}
82+
}
83+
6984
macro _ns {
7085
case { _ $ns $sexprs ... } => {
7186
var nsname = unwrapSyntax(#{$ns});
@@ -572,6 +587,22 @@ macro _sexpr {
572587
throw(_sexpr $x);
573588
}.call(this))
574589
}
590+
591+
rule { (+ $args ...) } => {
592+
_throw +
593+
}
594+
595+
rule { (- $args ...) } => {
596+
_throw -
597+
}
598+
599+
rule { (* $args ...) } => {
600+
_throw *
601+
}
602+
603+
//rule { (/ $args ...) } => {
604+
// _throw /
605+
//}
575606

576607
rule { ($[.] $fn $obj $args ...) } => {
577608
_sexpr $obj . $fn (_args ($args ...))

test/core.js

-1
Original file line numberDiff line numberDiff line change
@@ -743,5 +743,4 @@ describe("destructuring", function() {
743743
expect(r).to.eql(true);
744744
});
745745

746-
747746
});

0 commit comments

Comments
 (0)