Fixes to file and repl
This commit is contained in:
parent
64f620b2ef
commit
35a6f4537f
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 = "<STDIN>"
|
||||
|
|
@ -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: <TOKEN STRING>")
|
||||
elif t == "Callable":
|
||||
elif t == StackType.CALLABLE:
|
||||
print("#0: <CALLABLE>")
|
||||
else:
|
||||
print(f"#0: <UNKNOWN {t}>")
|
||||
|
|
|
|||
Loading…
Reference in New Issue