KEYWORDS = {
'var':'VARIABLE',
'=':'RESERVED',
'==':'EQUAL',
'>':'GT',
'<':"LT",
'(':'LPARENT',
')':'RPARENT',
'()':'PARENTS',
'class':"main_word",
'func':'main_word',
}
LINE = input("> ") #shell
def lex(LINE,KEYWORDS): #функция
ret = []
lines = LINE.split()
for line in lines:
if line in KEYWORDS:
ret.append((line, KEYWORDS[line]))
else:
ret.append((line, '?')) #если неизвестен кейворд
return ret
# Мне надо получить
tokens = lex(LINE,KEYWORDS)
print(tokens)