diff --git a/src/Interpreter.py b/src/Interpreter.py index f0e6ad8..8008ee1 100644 --- a/src/Interpreter.py +++ b/src/Interpreter.py @@ -230,12 +230,13 @@ def validate_range_node(range_node): @return int: The validated range value. @raise InterpreterError: If the range value is not an integer. """ - try: - runtime_object = range_node.accept(self) - return int(runtime_object.value) - except ValueError: - raise InterpreterError(ErrorType.RUNTIME, "Range value must be integers", + runtime_object = range_node.accept(self) + if type(runtime_object.value) is not int: + raise InterpreterError(ErrorType.RUNTIME, + f"Range value '{type(runtime_object.value).__name__}' " + f"cannot be used as an integer", range_node.start_pos, range_node.end_pos) + return runtime_object.value range_start = validate_range_node(node.range_start) range_end = validate_range_node(node.range_end) @@ -487,12 +488,10 @@ def visit_factor(self, node: 'FactorNode'): return RunTimeObject("boolean", not right_factor.value) elif left_factor.value == '-': - if right_factor.label == "number": + try: return RunTimeObject("number", -right_factor.value) - - raise InterpreterError(ErrorType.TYPE, - f"Value '{right_factor.value}' of variable is not a numeric type", - self.node_start_pos, self.node_end_pos) + except TypeError as e: + raise InterpreterError(ErrorType.TYPE, e.args[0], self.node_start_pos, self.node_end_pos) return left_factor @staticmethod diff --git a/src/Parser.py b/src/Parser.py index 5342b93..c55cdb7 100644 --- a/src/Parser.py +++ b/src/Parser.py @@ -230,9 +230,6 @@ def parse_statement(self): statement_node = self.parse_print() elif self.match(TokenType.INPUT): statement_node = self.parse_input() - else: - raise ParserError("Unexpected token: " + self.curr_tkn.value, - self.curr_tkn.line_num, self.curr_tkn.column_num) statement_node.start_pos = start_pos statement_node.end_pos = self.curr_tkn.pos diff --git a/test.py b/test.py index 5b78591..8e0add6 100644 --- a/test.py +++ b/test.py @@ -19,7 +19,7 @@ def setUp(self): self.lexer = Lexer() self.parser = Parser() self.interpreter = Interpreter() - self.num_random_tests = 50000 + self.num_random_tests = 25000 def tearDown(self): self.lexer = None @@ -48,12 +48,47 @@ def test_lexer(self): print(e, file=sys.stderr) self.fail() + def test_lexer_errors(self): + header = "Testing Lexer Errors" + print(header) + print(f"-" * len(header)) + + test_dir = os.path.join(self.test_dir, "errors/lexer/") + for file in os.listdir(test_dir): + if not file.endswith(".lex"): + continue + + output_file = file.replace(".lex", ".out") + with open(os.path.join(test_dir, output_file)) as f: + expected = f.read() + + print(f"[Lexer Error] Running test on: {file}") + try: + self.lexer.analyze_src_file(test_dir + file) + + token = Token() + while token.type != TokenType.ENDMARKER: + token = self.lexer.get_token() + print(" ", token) + + self.fail() + except Exception as e: + if expected.lower() not in str(e).lower(): + print(expected in str(e)) + print(e) + self.fail(f"EXPECTED:\n" + f" {expected}\n" + f"ACTUAL:\n" + f" {e}") + finally: + self.lexer.__init__() + def test_parser(self): header = "Testing Parser" print(header) print(f"-" * len(header)) - test_dir = os.path.join(self.test_dir, "parser/") + test_dir = os.path.join(self.test_dir, "interpreter/in/") for file in os.listdir(test_dir): print(f"[Parser] Running test on: {file}") @@ -112,6 +147,33 @@ def test_interpreter(self): if failed: self.fail() + def test_interpreter_errors(self): + header = "Testing Interpreter Errors" + print(header) + print(f"-" * len(header)) + + test_dir = os.path.join(self.test_dir, "errors/interpreter/") + for file in os.listdir(test_dir): + if not file.endswith(".ny"): + continue + + output_file = file.replace(".ny", ".out") + with open(os.path.join(test_dir, output_file)) as f: + expected = f.read() + + proc = subprocess.run( + ["python3", "nyaa.py", test_dir + file], + capture_output=True, + text=True + ) + + print(f"[Interpreter Error] Running test on: {file}") + if expected.lower().strip() not in str(proc.stderr).lower().strip(): + self.fail(f"EXPECTED:\n" + f" {expected}\n" + f"ACTUAL:\n" + f" {proc.stderr}") + def test_operator_precedence_expressions(self): header = "Testing Operator Precedence Expressions" print(header) @@ -167,7 +229,7 @@ def test_prioritized_expressions(self): start = -sys.maxsize - 1 end = sys.maxsize - for _ in range(self.num_random_tests // 10): + for _ in range(self.num_random_tests // 2): a = random.randint(start, end) b = random.randint(start, end) c = random.randint(start, end) diff --git a/tests/errors/lexer/identifier_too_long.lex b/tests/errors/lexer/identifier_too_long.lex new file mode 100644 index 0000000..810eb18 --- /dev/null +++ b/tests/errors/lexer/identifier_too_long.lex @@ -0,0 +1 @@ +eiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouv \ No newline at end of file diff --git a/tests/errors/lexer/identifier_too_long.out b/tests/errors/lexer/identifier_too_long.out new file mode 100644 index 0000000..748988d --- /dev/null +++ b/tests/errors/lexer/identifier_too_long.out @@ -0,0 +1 @@ +Identifier exceeds the maximum length \ No newline at end of file diff --git a/tests/errors/lexer/invalid_escape_char.lex b/tests/errors/lexer/invalid_escape_char.lex new file mode 100644 index 0000000..7e02902 --- /dev/null +++ b/tests/errors/lexer/invalid_escape_char.lex @@ -0,0 +1 @@ +"\0" \ No newline at end of file diff --git a/tests/errors/lexer/invalid_escape_char.out b/tests/errors/lexer/invalid_escape_char.out new file mode 100644 index 0000000..3a75c00 --- /dev/null +++ b/tests/errors/lexer/invalid_escape_char.out @@ -0,0 +1 @@ +Invalid escape character \ No newline at end of file diff --git a/tests/errors/lexer/string_too_long.lex b/tests/errors/lexer/string_too_long.lex new file mode 100644 index 0000000..af71d4d --- /dev/null +++ b/tests/errors/lexer/string_too_long.lex @@ -0,0 +1 @@ +"eiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouveiohfoiefhioehfiofheiohfwegvbvjbveuirbevoiubfvouv" \ No newline at end of file diff --git a/tests/errors/lexer/string_too_long.out b/tests/errors/lexer/string_too_long.out new file mode 100644 index 0000000..d7ccf6d --- /dev/null +++ b/tests/errors/lexer/string_too_long.out @@ -0,0 +1 @@ +String too long \ No newline at end of file diff --git a/tests/errors/lexer/unrecognized_char.lex b/tests/errors/lexer/unrecognized_char.lex new file mode 100644 index 0000000..2350720 --- /dev/null +++ b/tests/errors/lexer/unrecognized_char.lex @@ -0,0 +1 @@ +/?\@^\| \ No newline at end of file diff --git a/tests/errors/lexer/unrecognized_char.out b/tests/errors/lexer/unrecognized_char.out new file mode 100644 index 0000000..3726cf3 --- /dev/null +++ b/tests/errors/lexer/unrecognized_char.out @@ -0,0 +1 @@ +Unrecognized character \ No newline at end of file diff --git a/tests/errors/lexer/unterminated_string.lex b/tests/errors/lexer/unterminated_string.lex new file mode 100644 index 0000000..01487a4 --- /dev/null +++ b/tests/errors/lexer/unterminated_string.lex @@ -0,0 +1 @@ +"dfkfgoiggghmgh \ No newline at end of file diff --git a/tests/errors/lexer/unterminated_string.out b/tests/errors/lexer/unterminated_string.out new file mode 100644 index 0000000..dfec588 --- /dev/null +++ b/tests/errors/lexer/unterminated_string.out @@ -0,0 +1 @@ +Unterminated string \ No newline at end of file diff --git a/tests/interpreter/in/for.ny b/tests/interpreter/in/for.ny index ae74368..ef52f22 100644 --- a/tests/interpreter/in/for.ny +++ b/tests/interpreter/in/for.ny @@ -25,17 +25,18 @@ uWu_nyaa() => { } yomu() - for i => (1 supuritto 1, 10) { + a wa 10 + for i => (1, a) { yomu(i) } yomu() - for i => (IIE, HAI) { + for i => (0, 1) { yomu(i) } yomu() - for _ => (HAI, IIE) { + for _ => (1, 0) { yomu(_) } yomu(_) diff --git a/tests/parser/1toN.ny b/tests/parser/1toN.ny deleted file mode 100644 index a1aa9a8..0000000 --- a/tests/parser/1toN.ny +++ /dev/null @@ -1,13 +0,0 @@ -kawaii inc(x, N) => { - # if (N == 0): return - nani (N == 0) { modoru } - - yomu(x) # print(x) - - # inc(x + 1, N - 1) - inc(x purasu 1, N mainasu 1) -} - -uWu_nyaa() => { - inc(1, 10) -} \ No newline at end of file diff --git a/tests/parser/OneLineMain.ny b/tests/parser/OneLineMain.ny deleted file mode 100644 index d3c9ad6..0000000 --- a/tests/parser/OneLineMain.ny +++ /dev/null @@ -1 +0,0 @@ -uWu_nyaa() => modoru 2; \ No newline at end of file diff --git a/tests/parser/add.ny b/tests/parser/add.ny deleted file mode 100644 index 1ae636a..0000000 --- a/tests/parser/add.ny +++ /dev/null @@ -1,2 +0,0 @@ -# Simple addition of numbers and prints the result -uWu_nyaa() => yomu(1 purasu 1); \ No newline at end of file diff --git a/tests/parser/assign_and_use.ny b/tests/parser/assign_and_use.ny deleted file mode 100644 index 557c6dd..0000000 --- a/tests/parser/assign_and_use.ny +++ /dev/null @@ -1,5 +0,0 @@ -uWu_nyaa() => { - # Assign "Nyaa-chan" to the variable name - name wa "Nyaa-chan" - yomu(name) # Print value of name -} \ No newline at end of file diff --git a/tests/parser/assignment.ny b/tests/parser/assignment.ny deleted file mode 100644 index 300e358..0000000 --- a/tests/parser/assignment.ny +++ /dev/null @@ -1,3 +0,0 @@ -uWu_nyaa() => { - name wa "Nyaa-chan" -} \ No newline at end of file diff --git a/tests/parser/complex_expr.ny b/tests/parser/complex_expr.ny deleted file mode 100644 index 3b37033..0000000 --- a/tests/parser/complex_expr.ny +++ /dev/null @@ -1,13 +0,0 @@ -uWu_nyaa() => { - # B = 3 + (-4 + 4 + (4 * 4)) - B wa 3 purasu (-4 purasu 4 purasu (4 purodakuto 4)) - yomu(B) # print value of B - - # (3 + 4) * 1 == ((7 * 2)) - 7) - B wa (3 purasu 4) purodakuto 1 == ((7 purodakuto 2) mainasu 7) - yomu(B) - - # ((-5 * 2) == (0 - 10)) && ((2 * -5) == -10) - B wa ((-5 purodakuto 2) == (0 mainasu 10)) ando ((2 purodakuto -5) == -10) - yomu(B) -} diff --git a/tests/parser/div-err.ny b/tests/parser/div-err.ny deleted file mode 100644 index b05731e..0000000 --- a/tests/parser/div-err.ny +++ /dev/null @@ -1,3 +0,0 @@ -uWu_nyaa() => { - x wa 10 supuritto 0 # x = 10 / 0 -} \ No newline at end of file diff --git a/tests/parser/div.ny b/tests/parser/div.ny deleted file mode 100644 index ba61e3f..0000000 --- a/tests/parser/div.ny +++ /dev/null @@ -1,2 +0,0 @@ -# Simple addition of numbers and prints the result -uWu_nyaa() => yomu(64 supuritto 2); \ No newline at end of file diff --git a/tests/parser/eof.ny b/tests/parser/eof.ny deleted file mode 100644 index c3a23c2..0000000 --- a/tests/parser/eof.ny +++ /dev/null @@ -1 +0,0 @@ -uWu_nyaa() => {} diff --git a/tests/parser/factorial.ny b/tests/parser/factorial.ny deleted file mode 100644 index 30d71df..0000000 --- a/tests/parser/factorial.ny +++ /dev/null @@ -1,16 +0,0 @@ -# Factorial implementation function -kawaii factorial(x) => { - # if x == 0 - nani(x == 0) { - modoru 1 # return 1 - } - - # return x * factorial(x - 1) - modoru x purodakuto factorial(x mainasu 1) -} - -# Main program block -uWu_nyaa() => { - # print result of factorial(5) - yomu(factorial(5)) -} diff --git a/tests/parser/fib.ny b/tests/parser/fib.ny deleted file mode 100644 index be9879c..0000000 --- a/tests/parser/fib.ny +++ /dev/null @@ -1,10 +0,0 @@ -kawaii fib(x) => { - nani (x <= 1) { - modoru x - } - modoru fib(x mainasu 1) purasu fib(x mainasu 2) -} - -uWu_nyaa() => { - yomu(fib(20)) -} \ No newline at end of file diff --git a/tests/parser/float_add.ny b/tests/parser/float_add.ny deleted file mode 100644 index cf74f30..0000000 --- a/tests/parser/float_add.ny +++ /dev/null @@ -1,4 +0,0 @@ -uWu_nyaa() => { - B wa 3.142 purasu (-4.2 purasu 4.5 purasu (4.8635 purodakuto 69.69)) - yomu(B) -} \ No newline at end of file diff --git a/tests/parser/for.ny b/tests/parser/for.ny deleted file mode 100644 index ae74368..0000000 --- a/tests/parser/for.ny +++ /dev/null @@ -1,42 +0,0 @@ -kawaii test(start, end) => { - for i => (start, end) { - yomu(i) - } - yomu() -} - -uWu_nyaa() => { - # Test ranges using identifiers - test(0, 1) - test(0, 10) - test(10, 0) - test(1, 1) - test(-5, 5) - - # Test raw values - # - for i => (0, 10) { - yomu(i) - } - yomu() - - for _ => (0 purasu 1, 10 purodakuto 1) { - yomu(_) - } - yomu() - - for i => (1 supuritto 1, 10) { - yomu(i) - } - yomu() - - for i => (IIE, HAI) { - yomu(i) - } - yomu() - - for _ => (HAI, IIE) { - yomu(_) - } - yomu(_) -} \ No newline at end of file diff --git a/tests/parser/func.ny b/tests/parser/func.ny deleted file mode 100644 index 6d185ef..0000000 --- a/tests/parser/func.ny +++ /dev/null @@ -1,8 +0,0 @@ -kawaii add() => { - modoru 2 purasu 3 -} - -uWu_nyaa() => { - a wa add() - yomu(a) -} diff --git a/tests/parser/func2.ny b/tests/parser/func2.ny deleted file mode 100644 index 9bcd951..0000000 --- a/tests/parser/func2.ny +++ /dev/null @@ -1,9 +0,0 @@ -kawaii add() => { - modoru 3 purodakuto 3 -} - -uWu_nyaa() => { - a wa 3 - a wa add() - yomu(a) -} diff --git a/tests/parser/hello.ny b/tests/parser/hello.ny deleted file mode 100644 index ab4aab4..0000000 --- a/tests/parser/hello.ny +++ /dev/null @@ -1,3 +0,0 @@ -uWu_nyaa() => { - yomu("Ohayo!") -} \ No newline at end of file diff --git a/tests/parser/if-elif-else.ny b/tests/parser/if-elif-else.ny deleted file mode 100644 index b39c7ec..0000000 --- a/tests/parser/if-elif-else.ny +++ /dev/null @@ -1,9 +0,0 @@ -uWu_nyaa() => { - test wa HAI - - nani (test) - {} - nandesuka (nai test) - { yomu(IIE) } - baka { yomu(IIE) } -} \ No newline at end of file diff --git a/tests/parser/if-elif.ny b/tests/parser/if-elif.ny deleted file mode 100644 index 60f200a..0000000 --- a/tests/parser/if-elif.ny +++ /dev/null @@ -1,8 +0,0 @@ -uWu_nyaa() => { - test wa HAI - - nani (test) { - } nandesuka (nai test) { - yomu(IIE) - } -} \ No newline at end of file diff --git a/tests/parser/if-else.ny b/tests/parser/if-else.ny deleted file mode 100644 index e918cae..0000000 --- a/tests/parser/if-else.ny +++ /dev/null @@ -1,13 +0,0 @@ -kawaii test(x, y) => { - nani(x == y) { - yomu("Oui") - } baka { - yomu("Non") - } -} - -uWu_nyaa() => { - a wa 10 - b wa 10 - test(a, b) -} diff --git a/tests/parser/if.ny b/tests/parser/if.ny deleted file mode 100644 index 2f767f0..0000000 --- a/tests/parser/if.ny +++ /dev/null @@ -1,5 +0,0 @@ -uWu_nyaa() => { - nani (HAI) { - yomu(HAI) - } -} \ No newline at end of file diff --git a/tests/parser/input.ny b/tests/parser/input.ny deleted file mode 100644 index 808afc0..0000000 --- a/tests/parser/input.ny +++ /dev/null @@ -1,4 +0,0 @@ -uWu_nyaa() => { - name wa ohayo("Enter your name: ") - yomu("Ohayo,", name, "!") -} \ No newline at end of file diff --git a/tests/parser/mul.ny b/tests/parser/mul.ny deleted file mode 100644 index b8ec4fd..0000000 --- a/tests/parser/mul.ny +++ /dev/null @@ -1,2 +0,0 @@ -# Simple addition of numbers and prints the result -uWu_nyaa() => yomu(8 purodakuto 4); \ No newline at end of file diff --git a/tests/parser/num_guess.ny b/tests/parser/num_guess.ny deleted file mode 100644 index 2350e39..0000000 --- a/tests/parser/num_guess.ny +++ /dev/null @@ -1,24 +0,0 @@ -uWu_nyaa() => { - yomu("Welcome to the guessing game!") - - num_to_guess wa 10 - guesses_left wa 5 - guess wa 5 - - yomu("Guess the number...") - yomu("You have", guesses_left, "left") - - # Game loop - daijoubu (guesses_left != 0) { - guess++ - - # Check if guessed number is correct - nani (guess == num_to_guess) { - yomu("You guessed the correct number!") - guesses_left wa 0 - } baka { - guesses_left-- - yomu("You have", guesses_left, "left") - } - } -} diff --git a/tests/parser/print_input.ny b/tests/parser/print_input.ny deleted file mode 100644 index c66daba..0000000 --- a/tests/parser/print_input.ny +++ /dev/null @@ -1,3 +0,0 @@ -uWu_nyaa() => { - yomu(ohayo("Enter name: ")) -} \ No newline at end of file diff --git a/tests/parser/random.ny b/tests/parser/random.ny deleted file mode 100644 index 0fb2ecb..0000000 --- a/tests/parser/random.ny +++ /dev/null @@ -1,55 +0,0 @@ -kawaii add(x, y) => { - modoru x mainasu y -} - -kawaii sub() => { - modoru 69 -} - -kawaii div() => { - modoru 69 -} - - -uWu_nyaa() => { - a wa 3 - yomu(add(15, 5)) - yomu("hello", "world!") - yomu(nai a) - a wa 32 - - i wa 100 - yomu(i) - - b wa -5 purasu (3 purodakuto 2) - b wa 4 - b wa ((4 purasu 4)) - a wa (a purasu (b mainasu a)) - a wa -a - a++ - a-- - a wa -a purasu b - yomu("test") - yomu(a ando nai b) - - a++ - a wa (a purasu b) - b-- - yomu(HAI) - yomu(IIE) - ohayo() - - daijoubu (a < 1000) { - a++ - } - - nani (test) { - yomu() - add(2, 3) - } nandesuka (nai test) { - yomu() - } baka { - lol() - } - -} diff --git a/tests/parser/simple.ny b/tests/parser/simple.ny deleted file mode 100644 index 4123d10..0000000 --- a/tests/parser/simple.ny +++ /dev/null @@ -1,3 +0,0 @@ -uWu_nyaa() => { - modoru -} \ No newline at end of file diff --git a/tests/parser/sub.ny b/tests/parser/sub.ny deleted file mode 100644 index 0c45fdb..0000000 --- a/tests/parser/sub.ny +++ /dev/null @@ -1,2 +0,0 @@ -# Simple addition of numbers and prints the result -uWu_nyaa() => yomu(1 mainasu 1); \ No newline at end of file diff --git a/tests/parser/up_down.ny b/tests/parser/up_down.ny deleted file mode 100644 index 66aa34f..0000000 --- a/tests/parser/up_down.ny +++ /dev/null @@ -1,17 +0,0 @@ -uWu_nyaa() => { - n wa 0 - - daijoubu(n <= 100) { - yomu(n) - n++ - - nani(n == 100) { - daijoubu(n >= 0) { - yomu(n) - n-- - } - } - - nani (n == -1) { yamete } - } -} \ No newline at end of file diff --git a/tests/parser/while.ny b/tests/parser/while.ny deleted file mode 100644 index 4296710..0000000 --- a/tests/parser/while.ny +++ /dev/null @@ -1,8 +0,0 @@ -uWu_nyaa() => { - a wa 0 - - daijoubu (a <= 10) { - yomu(a) - a++ - } -} \ No newline at end of file