feat(runner): add REPL welcome message and language version

This commit is contained in:
2026-02-07 02:09:52 +01:00
parent e948091c16
commit 7e426ab070
3 changed files with 15 additions and 1 deletions

View File

@@ -1,2 +1,3 @@
MAX_FUNCTION_ARGS = 255
CONSTRUCTOR_NAME = "init"
VERSION = (0, 1, 0)

View File

@@ -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 = ""

View File

@@ -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
try:
interpreter.interpret(program)
except KeyboardInterrupt:
print()
if Pebble.had_runtime_error:
Pebble.had_runtime_error = False