mirror of
https://github.com/Alvin-Zilverstand/femcode.git
synced 2026-03-06 02:56:56 +01:00
feat: Update main.py to accept file path as command-line argument
This commit is contained in:
14
src/main.py
14
src/main.py
@@ -1,10 +1,20 @@
|
|||||||
|
import sys
|
||||||
from lexer import Lexer
|
from lexer import Lexer
|
||||||
from parser import Parser
|
from parser import Parser
|
||||||
from interpreter import Interpreter
|
from interpreter import Interpreter
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with open('../examples/variables.fem', 'r') as f:
|
if len(sys.argv) < 2:
|
||||||
text = f.read()
|
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)
|
lexer = Lexer(text)
|
||||||
tokens = lexer.tokenize()
|
tokens = lexer.tokenize()
|
||||||
|
|||||||
Reference in New Issue
Block a user