diff --git a/examples/io.fem b/examples/io.fem new file mode 100644 index 0000000..960a36a --- /dev/null +++ b/examples/io.fem @@ -0,0 +1,2 @@ +name is ask("What's your name, femboy? ") +UwU Boy "Hello, " + name + "!" \ No newline at end of file diff --git a/src/interpreter.py b/src/interpreter.py index fd5c0bf..c26654a 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -2,7 +2,12 @@ class Interpreter: def __init__(self, ast): self.ast = ast self.scope_stack = [{}] - self.functions = {} + self.functions = { + "ask": self._ask_builtin + } + + def _ask_builtin(self, prompt): + return input(prompt) @property def current_scope(self): @@ -143,6 +148,11 @@ class Interpreter: # Evaluate arguments evaluated_arguments = [self.visit(arg) for arg in node.arguments] + # Check if it's a built-in function + if callable(func_info): + return func_info(*evaluated_arguments) + + # Existing logic for user-defined functions # Create a new scope for the function call new_scope = {} for i, param_name in enumerate(func_info['parameters']):