feat: Update main.py to accept file path as command-line argument

This commit is contained in:
Alvin
2025-07-22 18:32:34 +02:00
parent 633a550e13
commit 342f6c1c21

View File

@@ -1,10 +1,20 @@
import sys
from lexer import Lexer
from parser import Parser
from interpreter import Interpreter
def main():
with open('../examples/variables.fem', 'r') as f:
text = f.read()
if len(sys.argv) < 2:
print("Usage: python3 main.py <femcode_file>")
sys.exit(1)
file_path = sys.argv[1]
try:
with open(file_path, 'r') as f:
text = f.read()
except FileNotFoundError:
print(f"Error: File not found: {file_path}")
sys.exit(1)
lexer = Lexer(text)
tokens = lexer.tokenize()