Updated the tokenizer to include a method to replace variable tokens with the values provided in a list.
This commit is contained in:
+10
-4
@@ -69,10 +69,16 @@ def get_tokens_from_expression_string(expression_string):
|
||||
tokens.append(token.CToken(c + str(symbols_dic[c]), token.TokenType.variable))
|
||||
parsing_number = False
|
||||
tmp = ""
|
||||
#When building this list we've effectively ordered the tokens in reverse order from how we want to
|
||||
#process them. So, reverse the order of the list before returning them to the caller, we don't want
|
||||
#the caller to have to worry about such a minor detail.
|
||||
tokens.reverse()
|
||||
|
||||
return tokens
|
||||
|
||||
|
||||
def replace_variables(tokens, new_constants):
|
||||
newTokenList = []
|
||||
for t in tokens:
|
||||
if t.type == token.TokenType.variable:
|
||||
newTokenList.append(token.CToken(new_constants.pop(0), token.TokenType.constant))
|
||||
else:
|
||||
newTokenList.append(t)
|
||||
|
||||
return newTokenList
|
||||
|
||||
Reference in New Issue
Block a user