Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parser(code):
- index = 0
- type = ""
- value = ""
- comment = ""
- # setup
- new_variable = ""
- new_say = ""
- new_input = ""
- nothing = ""
- while index < len(code):
- type = code[index][0]
- value = code[index][1]
- # print(code)
- # Statement end
- if type == "STATEMENT_END" and value == ";":
- new_variable = ""
- new_say = ""
- new_input = ""
- # Comment
- if type == "COMMENT_START":
- comment = "true"
- elif type == "COMMENT_END":
- comment = ""
- elif comment == "true":
- nothing = ""
- # new variable
- elif new_variable != "":
- if type == "STRING" or type == "INTEGER":
- exec("script_" + new_variable + ' = "' + value + '"')
- else:
- exec("script_" + new_variable + " = " + value)
- # new input
- elif new_input != "":
- if type == "STRING" or type == "INTEGER":
- exec("script_" + new_input + ' = input("' + value + '")')
- else:
- exec("script_" + new_input + ' = input("' + value + '")')
- # input
- elif type == "INPUT":
- new_input = value
- # say
- elif new_say == "true":
- value = (value)
- if type == "GET_VAR":
- exec('print(script_' + value + ")")
- elif type == "INTEGER":
- exec('print("' + str(value) + '")')
- else:
- exec('print("' + str(value) + '")')
- new_say = ""
- # if else elif stuff hard
- # elif type == "IF":
- # stuff
- elif type == "IDENTIFIER" and value == "say":
- new_say = "true"
- elif type == "VAR_DECLEARATION":
- new_variable = value
- index += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement