mirror of
https://github.com/Alvin-Zilverstand/femcode.git
synced 2026-03-06 11:06:47 +01:00
feat: Update main.py to accept file path as command-line argument
This commit is contained in:
12
src/main.py
12
src/main.py
@@ -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:
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user