Exemplo n.º 1
0
        string lineToParse = ""; // The current line to make sense of

        //                                                                                                                                        ||
        //                                                                                                                                        \/
        public Instruction(string instruction_string) // This is initialised upon creation of the object, Instruction testInstruction = new Instruction("test;");
        {
            instructionNumber   += 1;
            this.InstructionType = "null";                                                    // In case none of the following IFs are true

            string last_char = (instruction_string.Substring(instruction_string.Length - 1)); // Last character of the string

            if (last_char.Equals(";"))
            {
                this.InstructionType = "statement";
            }
            if (last_char.Equals("{") || last_char.Equals("}"))
            {
                IDs tempID = new IDs(); // Init obj before use so that we can use it in both cases for open & close
                if (last_char.Equals("{"))
                {
                    // Open new ID
                    tempID.IDGive(1, curleyBrackets);
                    this.ID = tempID;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("OPEN: {0}", tempID.IDString());
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else
                {
                    tempID.IDClose(curleyBrackets);
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("PREVIOUS CLOSED, NOW ON: {0}", tempID.MostRecentOpen(curleyBrackets).IDString());
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                this.InstructionType = "conductor";
            }
            this.Contents = instruction_string;
            lineToParse   = this.Contents; // Instruction is one line, so all of it is the line to parse
        }
Exemplo n.º 2
0
        public void AddID(List <object> FinalInstructions)
        {
            IDs temporaryPlaceholderID = new IDs();                                                    // Just a temporary ID to access the most recent ID function, it is not added to anything.

            curleyContents[temporaryPlaceholderID.MostRecentOpen(curleyBrackets)] = FinalInstructions; // Add the final instructions of that line to the dict with a key of the ID of the block (set of { } ) it is in.
        }