Exemple #1
0
        /********************************************************************
         *** FUNCTION    : Validate Expressions Function                   ***
         *** DESCRIPTION : This function loops through the expressions and ***
         ***               validates them and stores the valid expressions ***
         ***               into a node.                                    ***
         *** INPUT ARGS  : ExpressionsLinkedList expressionsLinkedList,    ***
         ***               BinarySearchTree symbolTable,                   ***
         ***               List<string> expressions                        ***
         *** OUTPUT ARGS : This function has zero output arguments.        ***
         *** IN/OUT ARGS : This function has zero input/output arguments.  ***
         *** RETURN      : This function returns nothing.                  ***
         *********************************************************************/
        public void ValidateExpressions(ExpressionsLinkedList expressionsLinkedList, BinarySearchTree symbolTable, List <string> expressions)
        {
            foreach (string expression in expressions)
            {
                // Validate the expression
                bool isValidExpression = ValidateExpression(expression);

                // Store expression into a node
                if (isValidExpression == true)
                {
                    ProcessExpression(expressionsLinkedList, symbolTable, expression);
                }
            }
        }
Exemple #2
0
        /********************************************************************
         *** FUNCTION    : Process File Function                           ***
         *** DESCRIPTION : This funciton gets the expression file name and ***
         ***               reads in the contents of the expression file    ***
         ***               into an array of strings. It then separates the ***
         ***               array of strings into literals and expressions. ***
         ***               It then validates the expressions and validates ***
         ***               the literals.                                   ***
         *** INPUT ARGS  : ExpressionsLinkedList expressionsLinkedList,    ***
         ***               LiteralsLinkedList literalsLinkedList,          ***
         ***               BinarySearchTree symbolTable, string arg = ""   ***
         *** OUTPUT ARGS : This function has zero output arguments.        ***
         *** IN/OUT ARGS : This function has zero input/output arguments.  ***
         *** RETURN      : This function returns nothing.                  ***
         *********************************************************************/
        public void ProcessFile(ExpressionsLinkedList expressionsLinkedList, LiteralsLinkedList literalsLinkedList, BinarySearchTree symbolTable, string arg = "")
        {
            // Get file name if it exists
            string expressionFileName = GetExpressionFile(arg);

            // Read in the expression file and save it into a string array
            string[] fileContents = GetExpressionFileContents(expressionFileName);

            // Separate the file contents into literals and expressions
            SeparateFileContents(fileContents);

            // Validate the expressions
            ExpressionValidator expressionValidator = new ExpressionValidator();

            expressionValidator.ValidateExpressions(expressionsLinkedList, symbolTable, expressions);

            // Validate the literals
            LiteralValidator literalValidator = new LiteralValidator();

            literalValidator.Validate(literalsLinkedList, literals);
        }
        static void Main(string[] args)
        {
            BinarySearchTree        binarySearchTree      = new BinarySearchTree();
            PopulateSymbolTable     symbolTable           = new PopulateSymbolTable();
            PopulateExpressionTable expressionTable       = new PopulateExpressionTable();
            ExpressionsLinkedList   expressionsLinkedList = new ExpressionsLinkedList();
            LiteralsLinkedList      literalsLinkedList    = new LiteralsLinkedList();

            // 1. Read from SYMS.DAT file and populate the symbol table
            binarySearchTree = symbolTable.CreateBinarySearchTreeFromDataFile();

            // 2. Create expressions
            if (args.Length > 0)
            {
                expressionTable.ProcessFile(expressionsLinkedList, literalsLinkedList, binarySearchTree, args[0]);
            }
            else
            {
                expressionTable.ProcessFile(expressionsLinkedList, literalsLinkedList, binarySearchTree);
            }

            Console.ReadKey();

            // 3. Display expression data
            expressionsLinkedList.Display();

            Console.ReadKey();

            // 4. Display literal error data
            literalsLinkedList.DisplayErrors();

            Console.ReadKey();

            // 5. Display literal data
            literalsLinkedList.Display();

            Console.ReadKey();
        }
Exemple #4
0
 /********************************************************************
  *** FUNCTION    : Process Expression Function                     ***
  *** DESCRIPTION : This function checks to see if an expression    ***
  ***               uses indirect, immediate, indexed, or direct    ***
  ***               addressing and then processes the expression.   ***
  *** INPUT ARGS  : ExpressionsLinkedList expressionsLinkedList,    ***
  ***               BinarySearchTree symbolTable, string expression ***
  *** OUTPUT ARGS : This function has zero output arguments.        ***
  *** IN/OUT ARGS : This function has zero input/output arguments.  ***
  *** RETURN      : This function returns nothing.                  ***
  *********************************************************************/
 private void ProcessExpression(ExpressionsLinkedList expressionsLinkedList, BinarySearchTree symbolTable, string expression)
 {
     // Process the valid expression
     if (expression[0] == '@') // Indirect
     {
         ProcessIndirectAddressing processIndirectAddressing = new ProcessIndirectAddressing();
         processIndirectAddressing.Process(expressionsLinkedList, symbolTable, expression);
     }
     else if (expression[0] == '#') // Immediate
     {
         ProcessImmediateAddressing processImmediateAddressing = new ProcessImmediateAddressing();
         processImmediateAddressing.Process(expressionsLinkedList, symbolTable, expression);
     }
     else if (expression.Contains(",")) // Indexed
     {
         ProcessIndexedAddressing processIndexedAddressing = new ProcessIndexedAddressing();
         processIndexedAddressing.Process(expressionsLinkedList, symbolTable, expression);
     }
     else // Direct
     {
         ProcessDirectAddressing processDirectAddressing = new ProcessDirectAddressing();
         processDirectAddressing.Process(expressionsLinkedList, symbolTable, expression);
     }
 }
Exemple #5
0
        /********************************************************************
         *** FUNCTION    : Process Function                                ***
         *** DESCRIPTION : This function processes an expression that      ***
         ***               utilizes indirect addressing.                   ***
         *** INPUT ARGS  : ExpressionsLinkedList expressionsLinkedList,    ***
         ***               BinarySearchTree symbolTable, string expression ***
         *** OUTPUT ARGS : This function has zero output arguments.        ***
         *** IN/OUT ARGS : This function has zero input/output arguments.  ***
         *** RETURN      : This function returns nothing.                  ***
         *********************************************************************/
        public void Process(ExpressionsLinkedList expressionsLinkedList, BinarySearchTree symbolTable, string expression)
        {
            string substring, primary, secondary;
            int    final;
            bool   dupestring = false;

            string[] tempStrippedStatement;
            tempStrippedStatement = expression.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);

            // Checks for subtraction
            if (tempStrippedStatement[0].Contains('-'))
            {
                tempStrippedStatement = tempStrippedStatement[0].Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                if (tempStrippedStatement.Count() != 1)
                {
                    dupestring = expressionsLinkedList.SearchExpressions(expression);
                    if (!dupestring)
                    {
                        // ABSOLUTE - ABSOLUTE check
                        if (!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            Console.WriteLine("Error: The expression " + expression + " cannot perform any special addressing");
                        }
                        // ABSOLUTE - Symbol check
                        else if (!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            foundSymbol = symbolTable.Search(secondary);
                            if (foundSymbol != null)
                            {
                                if (foundSymbol.Rflag == false)
                                {
                                    final = Convert.ToInt32(primary) - foundSymbol.Value;
                                    ExpressionNode node = new ExpressionNode(expression, final, false, false, true, false, false);
                                    expressionsLinkedList.Add(node);
                                }
                                else
                                {
                                    Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (0 - 1)");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                            }
                        }
                        // Symbol - Symbol check
                        else if (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            symbolToAdd = symbolTable.Search(primary);
                            foundSymbol = symbolTable.Search(secondary);
                            if (symbolToAdd != null && foundSymbol != null)
                            {
                                final = symbolToAdd.Value - foundSymbol.Value;
                                if (symbolToAdd.Rflag)
                                {
                                    if (foundSymbol.Rflag)
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                                else
                                {
                                    if (foundSymbol.Rflag)
                                    {
                                        Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (0 - 1)");
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                            }
                            else
                            {
                                if (symbolToAdd == null)
                                {
                                    Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                                }
                                else if (foundSymbol == null)
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                        }
                        // Symbol - ABSOLUTE check
                        else if (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            foundSymbol = symbolTable.Search(primary);
                            if (foundSymbol != null)
                            {
                                final = foundSymbol.Value - Convert.ToInt32(secondary);
                                ExpressionNode node = new ExpressionNode(expression, final, foundSymbol.Rflag, false, true, false, false);
                                expressionsLinkedList.Add(node);
                            }
                            else
                            {
                                Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: The symbol " + expression + " is a duplicate expression");
                    }
                }
                else
                {
                    Console.WriteLine("Error: The expression " + expression + " cannot perform any special addressing");
                }
            }
            // Checks for addition
            else if (tempStrippedStatement[0].Contains('+'))
            {
                tempStrippedStatement = tempStrippedStatement[0].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                if (tempStrippedStatement.Count() != 1)
                {
                    dupestring = expressionsLinkedList.SearchExpressions(expression);
                    if (!dupestring)
                    {
                        // ABSOLUTE + ABSOLUTE check
                        if (!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            Console.WriteLine("Error: The expression " + expression + " cannot perform any special addressing");
                        }
                        // Symbol + ABSOLUTE  || ABSOLUTE + Symbol check
                        else if ((!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x))) || (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x))))
                        {
                            primary   = tempStrippedStatement[0];
                            secondary = tempStrippedStatement[1];
                            if (primary.Any(x => char.IsLetter(x)))
                            {
                                foundSymbol = symbolTable.Search(primary);
                                if (foundSymbol != null)
                                {
                                    final = foundSymbol.Value + Convert.ToInt32(secondary);
                                    ExpressionNode node = new ExpressionNode(expression, final, foundSymbol.Rflag, false, true, false, false);
                                    expressionsLinkedList.Add(node);
                                }
                                else
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                            else
                            {
                                foundSymbol = symbolTable.Search(secondary);
                                if (foundSymbol != null)
                                {
                                    final = Convert.ToInt32(primary) + foundSymbol.Value;
                                    ExpressionNode node = new ExpressionNode(expression, final, foundSymbol.Rflag, false, true, false, false);
                                    expressionsLinkedList.Add(node);
                                }
                                else
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                        }
                        // Symbol + Symbol check
                        else if (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            symbolToAdd = symbolTable.Search(primary);
                            foundSymbol = symbolTable.Search(secondary);
                            if (symbolToAdd != null && foundSymbol != null)
                            {
                                final = symbolToAdd.Value + foundSymbol.Value;
                                if (symbolToAdd.Rflag)
                                {
                                    if (foundSymbol.Rflag)
                                    {
                                        Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (1 + 1)");
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                                else
                                {
                                    if (foundSymbol.Rflag)
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, false, true, false, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                            }
                            else
                            {
                                if (symbolToAdd == null)
                                {
                                    Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                                }
                                else if (foundSymbol == null)
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: The symbol " + expression + " is a duplicate expression");
                    }
                }
                else
                {
                    Console.WriteLine("Error: The symbol " + expression + " contains an invalid character");
                }
            }
            // No addition or subtraction
            else
            {
                Regex rg = new Regex(@"^[a-zA-Z0-9]+$");
                if (rg.IsMatch(tempStrippedStatement[0]))
                {
                    if (tempStrippedStatement[0].Length < 17)
                    {
                        if (tempStrippedStatement[0].Length > 6)
                        {
                            substring = tempStrippedStatement[0].Substring(0, 6);
                        }
                        else
                        {
                            substring = tempStrippedStatement[0];
                        }

                        dupestring = expressionsLinkedList.SearchExpressions(substring);
                        if (!dupestring)
                        {
                            if (substring.Any(x => char.IsLetter(x)))
                            {
                                symbolToAdd = symbolTable.Search(substring);
                                try
                                {
                                    ExpressionNode node = new ExpressionNode(expression, symbolToAdd.Value, symbolToAdd.Rflag, false, true, false, false);
                                    expressionsLinkedList.Add(node);
                                }
                                catch
                                {
                                    Console.WriteLine("Error: The symbol " + substring + " was not found in the symbol table");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Error: The expression " + expression + " cannot perform any special addressing");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Error: The symbol " + substring + " is a duplicate symbol");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: Symbol maximum length of 17: " + expression);
                    }
                }
                else
                {
                    Console.WriteLine("Error: Expression cannot contain special characters: " + expression);
                }
            }
        }
Exemple #6
0
        /********************************************************************
         *** FUNCTION    : Process Function                                ***
         *** DESCRIPTION : This function processes an expression that      ***
         ***               utilizes direct addressing.                     ***
         *** INPUT ARGS  : ExpressionsLinkedList expressionsLinkedList,    ***
         ***               BinarySearchTree symbolTable, string expression ***
         *** OUTPUT ARGS : This function has zero output arguments.        ***
         *** IN/OUT ARGS : This function has zero input/output arguments.  ***
         *** RETURN      : This function returns nothing.                  ***
         *********************************************************************/
        public void Process(ExpressionsLinkedList expressionsLinkedList, BinarySearchTree symbolTable, string expression)
        {
            string substring, primary, secondary;
            int    final;

            string[] tempStrippedStatement;
            bool     dupestring = false;

            // Checks for subtraction
            if (expression.Contains("-"))
            {
                tempStrippedStatement = expression.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                if (tempStrippedStatement.Count() != 1)
                {
                    dupestring = expressionsLinkedList.SearchExpressions(expression);
                    if (!dupestring)
                    {
                        // ABSOLUTE - ABSOLUTE check
                        if (!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary   = tempStrippedStatement[0];
                            secondary = tempStrippedStatement[1];
                            final     = Convert.ToInt32(primary) - Convert.ToInt32(secondary);
                            ExpressionNode node = new ExpressionNode(expression, final, false, false, true, true, false); // Expression, Value, relocatable, direct, NBit, IBit, Xbit
                            expressionsLinkedList.Add(node);
                        }
                        // ABSOLUTE - Symbol check
                        else if (!tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary   = tempStrippedStatement[0];
                            secondary = tempStrippedStatement[1];
                            tempNode  = symbolTable.Search(secondary);
                            if (tempNode != null)
                            {
                                if (tempNode.Rflag == false)
                                {
                                    final = Convert.ToInt32(primary) - tempNode.Value;
                                    ExpressionNode node = new ExpressionNode(expression, final, false, true, true, true, false);
                                    expressionsLinkedList.Add(node);
                                }
                                else
                                {
                                    Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (0 - 1)");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                            }
                        }
                        // Symbol - Symbol check
                        else if (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            symbolToAdd = symbolTable.Search(primary);
                            tempNode    = symbolTable.Search(secondary);
                            if (symbolToAdd != null && tempNode != null)
                            {
                                final = symbolToAdd.Value - tempNode.Value;
                                if (symbolToAdd.Rflag)
                                {
                                    if (tempNode.Rflag)
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                                else
                                {
                                    if (tempNode.Rflag)
                                    {
                                        Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (0 - 1)");
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                            }
                            else
                            {
                                if (symbolToAdd == null)
                                {
                                    Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                                }
                                else if (tempNode == null)
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                        }
                        // Symbol - ABSOLUTE check
                        else if (tempStrippedStatement[0].Any(x => char.IsLetter(x)) && !tempStrippedStatement[1].Any(x => char.IsLetter(x)))
                        {
                            primary   = tempStrippedStatement[0];
                            secondary = tempStrippedStatement[1];
                            tempNode  = symbolTable.Search(primary);
                            if (tempNode != null)
                            {
                                final = tempNode.Value - Convert.ToInt32(secondary);
                                ExpressionNode node = new ExpressionNode(expression, final, tempNode.Rflag, true, true, true, false);
                                expressionsLinkedList.Add(node);
                            }
                            else
                            {
                                Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: The symbol " + expression + " is a duplicate expression");
                    }
                }
                else
                {
                    if (expression.Length < 17)
                    {
                        if (expression.Length > 6)
                        {
                            substring = expression.Substring(0, 6);
                        }
                        else
                        {
                            substring = expression;
                        }

                        dupestring = expressionsLinkedList.SearchExpressions(substring);
                        if (!dupestring)
                        {
                            ExpressionNode node = new ExpressionNode(substring, Convert.ToInt32(substring), false, false, true, true, false);
                            expressionsLinkedList.Add(node);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: Symbol maximum length of 17: " + expression);
                    }
                }
            }
            // Checks for addition
            else if (expression.Contains('+'))
            {
                tempStrippedStatement = expression.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                if (tempStrippedStatement.Count() != 1)
                {
                    dupestring = expressionsLinkedList.SearchExpressions(expression);
                    if (!dupestring)
                    {
                        bool firstContainsLetter  = tempStrippedStatement[0].Any(x => char.IsLetter(x));
                        bool secondContainsLetter = tempStrippedStatement[1].Any(x => char.IsLetter(x));

                        // ABSOLUTE + ABSOLUTE check
                        if (!firstContainsLetter && !secondContainsLetter)
                        {
                            primary   = tempStrippedStatement[0];
                            secondary = tempStrippedStatement[1];
                            final     = Convert.ToInt32(primary) + Convert.ToInt32(secondary);
                            ExpressionNode node = new ExpressionNode(expression, final, false, true, true, true, false);
                            expressionsLinkedList.Add(node);
                        }
                        // Symbol + Symbol check
                        else if (firstContainsLetter && secondContainsLetter)
                        {
                            primary     = tempStrippedStatement[0];
                            secondary   = tempStrippedStatement[1];
                            symbolToAdd = symbolTable.Search(primary);
                            tempNode    = symbolTable.Search(secondary);
                            if (symbolToAdd != null && tempNode != null)
                            {
                                final = symbolToAdd.Value + tempNode.Value;
                                if (symbolToAdd.Rflag)
                                {
                                    if (tempNode.Rflag)
                                    {
                                        Console.WriteLine("Error: The expression " + expression + " contains an invalid Rflag combination (1 + 1)");
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                                else
                                {
                                    if (tempNode.Rflag)
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, true, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                    else
                                    {
                                        ExpressionNode node = new ExpressionNode(expression, final, false, true, true, true, false);
                                        expressionsLinkedList.Add(node);
                                    }
                                }
                            }
                            else
                            {
                                if (symbolToAdd == null)
                                {
                                    Console.WriteLine("Error: The symbol " + primary + " was not found in the symbol table for the expression: " + expression);
                                }
                                else if (tempNode == null)
                                {
                                    Console.WriteLine("Error: The symbol " + secondary + " was not found in the symbol table for the expression: " + expression);
                                }
                            }
                        }
                        else // Symbol + ABSOLUTE || ABSOLUTE + Symbol check
                        {
                            string symbol;
                            string value;
                            if (firstContainsLetter)
                            {
                                symbol   = tempStrippedStatement[0];
                                value    = tempStrippedStatement[1];
                                tempNode = symbolTable.Search(symbol);
                            }
                            else
                            {
                                value    = tempStrippedStatement[0];
                                symbol   = tempStrippedStatement[1];
                                tempNode = symbolTable.Search(symbol);
                            }

                            if (tempNode != null)
                            {
                                final = Convert.ToInt32(value) + tempNode.Value;
                                ExpressionNode node = new ExpressionNode(expression, final, tempNode.Rflag, true, true, true, false);
                                expressionsLinkedList.Add(node);
                            }
                            else
                            {
                                Console.WriteLine("Error: The symbol " + symbol + " was not found in the symbol table for the expression: " + expression);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: The symbol " + expression + " is a duplicate expression");
                    }
                }
                else
                {
                    Console.WriteLine("Error: The symbol " + expression + " contains an invalid character");
                }
            }
            // No addition or subtraction
            else
            {
                if (expression.Length < 17)
                {
                    if (expression.Length > 6)
                    {
                        substring = expression.Substring(0, 6);
                    }
                    else
                    {
                        substring = expression;
                    }

                    dupestring = expressionsLinkedList.SearchExpressions(substring);
                    if (!dupestring)
                    {
                        if (expression.Any(x => char.IsLetter(x)))
                        {
                            symbolToAdd = symbolTable.Search(substring);
                            try
                            {
                                ExpressionNode node = new ExpressionNode(symbolToAdd.Symbol, symbolToAdd.Value, symbolToAdd.Rflag, true, true, true, false);
                                expressionsLinkedList.Add(node);
                            }
                            catch
                            {
                                Console.WriteLine("Error: The symbol " + substring + " was not found in the symbol table");
                            }
                        }
                        else
                        {
                            ExpressionNode node = new ExpressionNode(substring, Convert.ToInt32(substring), false, false, false, true, false);
                            expressionsLinkedList.Add(node);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error: The symbol " + substring + " is a duplicate symbol");
                    }
                }
                else
                {
                    Console.WriteLine("Error: Symbol maximum length of 17: " + expression);
                }
            }
        }