From 5ebdb9fc06a838ce425342e0c76e609ee81a2947 Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Fri, 12 Mar 2021 11:10:24 +1300 Subject: [PATCH] Fixed appending two variables --- Assignment 1/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index 7109de1..4e5d8e8 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -134,6 +134,13 @@ namespace Assignment_1 } #region Function Handling + /// + /// Handles the append x y case. + /// + /// + /// + /// + /// bool Append(Stream source, long lineStart = -1) { // If it wasn't explicitly set, assume line starts the length of 'append ' before the current position @@ -390,7 +397,6 @@ namespace Assignment_1 { s.Position--; string keyValue; - long t = FindExistingIdentifier(s, out keyValue); if (!Symbols.ContainsKey(keyValue)) @@ -413,6 +419,12 @@ namespace Assignment_1 { string identifier; long wordEnd = FindNextWord(s, out identifier); + if (identifier.EndsWith(';') && identifier.Length > 1) + { + // Remove the trailing semicolon from the parse & backtrack the identifier length one spot + identifier = identifier.TrimEnd(';'); + wordEnd--; + } // Lookup the value in the symbol table returnedKey = identifier; return wordEnd;