diff --git a/JAPL/parser.py b/JAPL/parser.py index 8fbf408..f808b1d 100644 --- a/JAPL/parser.py +++ b/JAPL/parser.py @@ -401,7 +401,10 @@ class Parser(object): while True: if len(parameters) >= 255: raise self.throw(self.peek(), "Cannot have more than 255 arguments") - parameters.append(self.consume(TokenType.ID, "Expecting parameter name")) + parameter = self.consume(TokenType.ID, "Expecting parameter name") + if parameter in parameters: + raise self.throw(self.peek(), "Multiple parameters with the same name in function declaration are not allowed") + parameters.append(parameter) if not self.match(TokenType.COMMA): break self.consume(TokenType.RP, "Unexpected error while parsing function declaration") diff --git a/JAPL/types/japlclass.py b/JAPL/types/japlclass.py index dbd9a80..7e51104 100644 --- a/JAPL/types/japlclass.py +++ b/JAPL/types/japlclass.py @@ -17,8 +17,11 @@ class JAPLClass(Callable): def get_method(self, name: str): if name in self.methods: return self.methods[name] - elif self.superclass and name in self.superclass.methods: - return self.superclass.methods[name] + superclass = self.superclass + while superclass: + if name in superclass.methods: + return superclass.methods[name] + superclass = superclass.superclass def __repr__(self): return f"" diff --git a/examples/fib.jpl b/examples/fib.jpl index 57c3018..0a97934 100644 --- a/examples/fib.jpl +++ b/examples/fib.jpl @@ -5,6 +5,8 @@ fun fib(n) { return fib(n - 2) + fib(n - 1); } -for (var i = 0; i < 20; i = i + 1) { - print fib(i); -} + +var start = clock(); +fib(30); +var end = clock() - start; +print(end); diff --git a/nimjapl/interpreter.nim b/nimjapl/interpreter.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/lexer.nim b/nimjapl/lexer.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/meta/classtype.nim b/nimjapl/meta/classtype.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/meta/expression.nim b/nimjapl/meta/expression.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/meta/functiontype.nim b/nimjapl/meta/functiontype.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/meta/statement.nim b/nimjapl/meta/statement.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/meta/tokentype.nim b/nimjapl/meta/tokentype.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/parser.nim b/nimjapl/parser.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/types/callable.nim b/nimjapl/types/callable.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/types/class.nim b/nimjapl/types/class.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/types/function.nim b/nimjapl/types/function.nim new file mode 100644 index 0000000..e69de29 diff --git a/nimjapl/types/instance.nim b/nimjapl/types/instance.nim new file mode 100644 index 0000000..e69de29