diff --git a/src/consts.py b/src/consts.py index 1c87b16..a807019 100644 --- a/src/consts.py +++ b/src/consts.py @@ -1,2 +1,3 @@ MAX_FUNCTION_ARGS = 255 CONSTRUCTOR_NAME = "init" +VERSION = (0, 1, 0) diff --git a/src/pebble.py b/src/pebble.py index b56d3cc..1f56b73 100644 --- a/src/pebble.py +++ b/src/pebble.py @@ -2,6 +2,7 @@ import sys from pathlib import Path from typing import Optional +from src.consts import VERSION from src.interpreter.error import PebbleRuntimeError from src.position import Position from src.token import Token, TokenType @@ -11,6 +12,11 @@ class Pebble: had_error: bool = False had_runtime_error: bool = False + @staticmethod + def version() -> str: + major, minor, patch = VERSION + return f"{major}.{minor}.{patch}" + @staticmethod def run_file(path: str | Path): source: str = "" diff --git a/src/runner.py b/src/runner.py index c14002e..46993cf 100644 --- a/src/runner.py +++ b/src/runner.py @@ -59,6 +59,9 @@ class Runner: interpreter: Interpreter = Interpreter() resolver: Resolver + print(f"Welcome to Pebble v{Pebble.version()}!") + print("Press CTRL+D to quit") + brace_depth: int paren_depth: int buf: str = "" @@ -110,7 +113,11 @@ class Runner: if Pebble.had_error: Pebble.had_error = False continue - interpreter.interpret(program) + + try: + interpreter.interpret(program) + except KeyboardInterrupt: + print() if Pebble.had_runtime_error: Pebble.had_runtime_error = False