示例#1
0
 public OperatorList()
 {
     OpList = new LinkList();
     OpList.addLink("ASSIGNOP", "=");
     OpList.addLink("PM", "+");
     OpList.addLink("PM", "-");
     OpList.addLink("MDM", "*");
     OpList.addLink("MDM", "/");
     OpList.addLink("MDM", "%");
     OpList.addLink("ROP", "<");
     OpList.addLink("ROP", ">");
     OpList.addLink("ROP", "<=");
     OpList.addLink("ROP", ">=");
     OpList.addLink("ROP", "~=");
     OpList.addLink("ROP", "==");
     OpList.addLink("COMPOUND_ASSIGN", "+=");
     OpList.addLink("COMPOUND_ASSIGN", "-=");
     OpList.addLink("COMPOUND_ASSIGN", "/=");
     OpList.addLink("COMPOUND_ASSIGN", "*=");
     OpList.addLink("COMPOUND_ASSIGN", "%=");
     OpList.addLink("DOTOP", ".");
 }
示例#2
0
        public void AddItemsInToken()
        {
            TokenList = new LinkList();
            Node   current   = BreakWordList_Clear.GetHead();
            string temp      = null;
            bool   boolValue = false;

            for (; current != null; current = current.NextValueAdd)
            {
                temp = current.ValuePart;
                string previous = temp;
                if (temp == "commentReturn")
                {
                    LineNo++;
                    continue;
                }
                if (temp == "Return")
                {
                    TokenList.CreateToken("NEWLINE", "newline", LineNo);
                    LineNo++;
                    continue;
                }

                boolValue = MatchBreakWord(temp);

                if (boolValue == true)
                {
                    TokenList.CreateToken(CLassPart, temp, LineNo);
                }
                else
                {
                    TokenList.CreateToken("InValid", temp, LineNo);
                }
            }
            TokenList.CreateToken("$", "$", LineNo);
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            f = false;
            richTextBox6.Text   = null;
            TokenList2          = new LinkList();
            LineNo              = 1;
            BreakWordList       = new LinkList();
            BreakWordList_Clear = new LinkList();
            // richTextBox2.Text = null;
            // richTextBox3.Text = null;
            allText      = richTextBox1.Text;
            StringLenght = allText.Length;
            //BreakWordFunction(allText);
            break_words(allText);

            // richTextBox2.Text = BreakWordList_Clear.DisplayList();

            AddItemsInToken();
            // richTextBox3.Text = TokenList.DisplayTokens();
            //SyntaxAnalyzer SA = new SyntaxAnalyzer(TokenList);


            CurrentNode123 = TokenList.GetHead();

            OutNextLine();

            richTextBox5.Text = TokenList2.DisplayTokens();

            SyntaxAnalyzer SA = new SyntaxAnalyzer(TokenList2);

            Do pa = new Do();


            pa = SA.ABS();

            if (pa.cppp == "Valid Syntax")
            {
                richTextBox4.Text = pa.cppp;
            }
            else
            {
                richTextBox4.Text = pa.cppp + "\n" + "Syntax Error on Line" + pa.cpline;
            }

            int i = 1;

            while (i < 100)
            {
                richTextBox6.Text += i + "\n";
                i++;
            }


            //StreamWriter streamWriter = new StreamWriter(@"C:\Users\Mahad Khan\source\repos\BreakWord\BreakWord\TokensFile.txt");
            //streamWriter.WriteLine(richTextBox3.Text);
            //streamWriter.Close();

            BreakWordList     = null;
            TokenList         = null;
            TokenList2        = null;
            richTextBox2.Text = SA.TypeDef.Dis();
            richTextBox3.Text = SA.FuncTable.DisplayTokens();
            richTextBox7.Text = SA.RetTE();
        }