for line in code_lines:
if line.startswith("#"):
var_name, _, value = line.partition(" like ")
if "add " in value:
_, var1, var2 = value.partition("add ")
var1 = var1.strip()
var2 = var2.strip()
variables[var_name.strip()] = variables[var1] + variables[var2]
else:
variables[var_name.strip()] = int(value)
elif line.startswith("OMG"):
message = re.findall(r'"(.*?)"', line)
if message:
print(message[0].format(**variables))
# Sample code
code = '''
#my_var like 10
OMG "Value of my_var: {my_var}"
#var1 like 5
#var2 like 7
#sum like add #var1 #var2
OMG "Sum of {var1} and {var2} is {sum}"
'''
Hey dolls, let me introduce you to the Kimmie programming language, it's like totally fab and easy to use!
To declare a variable, just use the hashtag symbol and the variable name, like this:
#my_var
To assign a value to the variable, use the word "like" followed by the value, like this:
#my_var like 10
To print out a message, use the word "OMG" followed by the message in double quotes, like this:
OMG "Hello, dolls!"
To add two variables together, use the word "add" followed by the two variables, like this:
#var1 like 5 #var2 like 7 #sum like add #var1 #var2