diff --git a/SLS_Python/sls_py/file.py b/SLS_Python/sls_py/file.py index 3d0c7f7..0290dd1 100644 --- a/SLS_Python/sls_py/file.py +++ b/SLS_Python/sls_py/file.py @@ -1,6 +1,6 @@ from pathlib import Path -from sls.lexer import LexerInfo, lexical_analysis, Token -from sls.interpreter import InterpreterState +from .lexer import LexerInfo, lexical_analysis, Token +from .interpreter import InterpreterState def exec_file(interpreter_state: InterpreterState, filename: str) -> bool: diff --git a/SLS_Python/sls_py/repl.py b/SLS_Python/sls_py/repl.py index e8b3fa6..e16c7e8 100644 --- a/SLS_Python/sls_py/repl.py +++ b/SLS_Python/sls_py/repl.py @@ -1,6 +1,6 @@ from .meta import print_version from .lexer import LexerInfo, lexical_analysis -from .interpreter import InterpreterState +from .interpreter import InterpreterState, StackType REPL_FILE_NAME = "" @@ -16,23 +16,25 @@ def print_top_of_stack(interpreter: InterpreterState) -> None: t = item.type - if t == "Identifier": + if t == StackType.IDENTIFIER: print(f"#0: ::{item.value}") - elif t in {"i64", "i32", "i16", "i8"}: + elif t == StackType.I64: + print(f"#0: {item.value}") + elif t in {StackType.I32, StackType.I16, StackType.I8}: print(f"#0: {item.value}:{t}") - elif t in {"u64", "u32", "u16", "u8"}: + elif t in {StackType.U64, StackType.U32, StackType.U16, StackType.U8}: print(f"#0: {item.value}:{t}") - elif t == "f32": + elif t == StackType.F32: print(f"#0: {item.value}:f32") - elif t == "f64": + elif t == StackType.F64: print(f"#0: {item.value}") - elif t == "char": + elif t == StackType.CHARACTER: print(f"#0: {item.value}") - elif t == "bool": + elif t == StackType.BOOLEAN: print("#0: TRUE" if item.value else "#0: FALSE") - elif t == "TokenString": + elif t == StackType.TOKEN_STRING: print("#0: ") - elif t == "Callable": + elif t == StackType.CALLABLE: print("#0: ") else: print(f"#0: ")