Added a check if the current value already exists (Closes #5)

This commit is contained in:
Brychan Dempsey 2021-03-17 13:55:42 +13:00
parent f7b7fc1b36
commit b371be43d6

View File

@ -233,6 +233,11 @@ namespace Assignment_1
{ {
throw new ParserException("Cannot assign a value to a reserved constant", 0, keyEndPos - (key.Length + 1)); throw new ParserException("Cannot assign a value to a reserved constant", 0, keyEndPos - (key.Length + 1));
} }
else if (Symbols.ContainsKey(key) && !checkExist)
{
// key already exists, remove it
Symbols.Remove(key);
}
source.Position = keyEndPos; source.Position = keyEndPos;
} }
return key; return key;