From b371be43d6a30edaba96429380cc47d0f318722d Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Wed, 17 Mar 2021 13:55:42 +1300 Subject: [PATCH] Added a check if the current value already exists (Closes #5) --- Assignment 1/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index 4cefba3..33742a7 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -233,6 +233,11 @@ namespace Assignment_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; } return key;