diff --git a/src/kiss/SpecialForms.hx b/src/kiss/SpecialForms.hx index d7212d35..5a0d160a 100644 --- a/src/kiss/SpecialForms.hx +++ b/src/kiss/SpecialForms.hx @@ -182,6 +182,16 @@ class SpecialForms { EReturn(k.convert(args[0])).withMacroPosOf(wholeExp); }; + map["break"] = (wholeExp:ReaderExp, args:Array, k:KissState) -> { + wholeExp.checkNumArgs(0, 0, "(break)"); + EBreak.withMacroPosOf(wholeExp); + }; + + map["continue"] = (wholeExp:ReaderExp, args:Array, k:KissState) -> { + wholeExp.checkNumArgs(0, 0, "(continue)"); + EContinue.withMacroPosOf(wholeExp); + }; + // TODO (case... ) for switch // Type check syntax: diff --git a/src/test/cases/BasicTestCase.hx b/src/test/cases/BasicTestCase.hx index 38f77dc4..f104f824 100644 --- a/src/test/cases/BasicTestCase.hx +++ b/src/test/cases/BasicTestCase.hx @@ -232,4 +232,8 @@ class BasicTestCase extends Test { function testFieldExps() { _testFieldExps(); } + + function testBreakContinue() { + _testBreakContinue(); + } } diff --git a/src/test/cases/BasicTestCase.kiss b/src/test/cases/BasicTestCase.kiss index 672d47b8..1247fb72 100644 --- a/src/test/cases/BasicTestCase.kiss +++ b/src/test/cases/BasicTestCase.kiss @@ -262,4 +262,16 @@ (defun _testFieldExps [] (Assert.equals "hey" (.trim " hey ")) - (Assert.equals "e" (.charAt (.trim " hey ") 1))) \ No newline at end of file + (Assert.equals "e" (.charAt (.trim " hey ") 1))) + +(defun _testBreakContinue [] + (let [[a b c] + (for val [1 2 3 4 5 6 7 8] + (if (> val 6) + (break) + (if (% val 2) + (continue) + val)))] + (Assert.equals 2 a) + (Assert.equals 4 b) + (Assert.equals 6 c))) \ No newline at end of file