diff --git a/README.md b/README.md index 76d86cd..63bcd29 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ ToDo List: - [ ] add basic number list support - [ ] add fully features strings support - [ ] add [classic problem solving](https://rosettacode.org) with code examples +- [ ] add Web Assembly support and publish a demo website ## Installation diff --git a/examples/sequence.ltor b/examples/sequence.ltor index b70df13..7d7c7cb 100644 --- a/examples/sequence.ltor +++ b/examples/sequence.ltor @@ -1,5 +1,5 @@ set i to 0 -while !(i = 10) do +while i < 10 do print_number(i) set i to i+1 end diff --git a/src/operate.c b/src/operate.c index d933c36..309841b 100644 --- a/src/operate.c +++ b/src/operate.c @@ -14,7 +14,9 @@ int is_operator(char candidate) { candidate == '=' || candidate == '!' || candidate == '&' || - candidate == '|' + candidate == '|' || + candidate == '>' || + candidate == '<' ); } @@ -83,6 +85,10 @@ int operate( res = m_float_pow(a, b); } else if (operator == '=') { res = (int) (a == b); + } else if (operator == '>') { + res = (int) (a > b); + } else if (operator == '<') { + res = (int) (a < b); } else { return 2; } @@ -105,6 +111,10 @@ int operate( res = integer_pow(aRepr, bRepr); } else if (operator == '=') { res = (int) (aRepr == bRepr); + } else if (operator == '<') { + res = (int) (aRepr < bRepr); + } else if (operator == '>') { + res = (int) (aRepr > bRepr); } else { return 2; } diff --git a/tests/test_evaluation.c b/tests/test_evaluation.c index 7188c3c..8a8ae3f 100644 --- a/tests/test_evaluation.c +++ b/tests/test_evaluation.c @@ -121,4 +121,16 @@ void test_evaluation() evaluate(state, "1 & (1 | 0)", &resVal, &resType); assert(resType == TYPE_INT); assert(1 == resVal); + + evaluate(state, "0 > 0", &resVal, &resType); + assert(resType == TYPE_INT); + assert(0 == resVal); + + evaluate(state, "-45 < 1", &resVal, &resType); + assert(resType == TYPE_INT); + assert(1 == resVal); + + evaluate(state, "5 > 0", &resVal, &resType); + assert(resType == TYPE_INT); + assert(1 == resVal); }