Last active
July 12, 2023 13:20
-
-
Save kerem3338/013eae3fd95ec0b55a7cace64fb38abc to your computer and use it in GitHub Desktop.
Basit bir kod yorumlayıcı
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#2021 Kakos kişiselleşirilmiş lisans © Zoda | |
#Bu kodu kişsel veya özel kullanım için modifiye edebilirsiniz | |
import os | |
import sys | |
tokens = [] | |
def open_file(file_name): | |
data = open(file_name, "r").read() | |
return data | |
def lex(contents): | |
content = list(contents) | |
tok = "" | |
state = 0 | |
string = "" | |
for char in content: | |
tok += char | |
if tok == " ": | |
tok="" | |
elif tok =="print": | |
tokens.append("PRİNT") | |
tok = "" | |
elif tok == "\"" or "'": | |
if state == 0: | |
state = 1 | |
elif state == 1: | |
tokens.append("STRİNG:" + string) | |
string = "" | |
state = 0 | |
elif state == 1: | |
string += char | |
tok = "" | |
print(tokens) | |
def run(): | |
data = open_file(fr"{os.getcwd()}\{input('file name:')}") #Thanks Bahadır54 | |
lex(data) | |
if __name__ == "__main__": | |
run() |
yes
single quoted strings is not working
tek tırnaklı dizeler çalışmıyor
i handle it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be better.