Opening File
Files:
local_lexer.pylocal_parser.py
main.py
test.lang
Image
main.py:
from local_lexer import Lexer
from local_parser import Parser
def main():
# Read the currect flow source code in test.lang and store it in a variable
content = ""
with open('test.lang', 'r') as file:
content = file.read()
#
# Lexer
#
# Calls the lexer class and initializes it with the source code
lex = Lexer(content)
# Make source code tokens
tokens = lex.tokenize()
#
# Parser
#
parse = Parser(tokens)
parse.parse()
main()
I want to double-click the "test.lang" file or drag the "test.lang" file on the main.py
and make it so the with open lines opens the file that previously had been dragged on the main.py
with open('file dragged', 'r') as file:
content = file.read()