Exemplo n.º 1
0
        //public void BreakWordFunction(string inputText)
        //{

        //    string temp = null;
        //    string flag1 = null;
        //    string temp1 = null;
        //    char flagChar;

        //    int strLenght = inputText.Length;

        //    for (int i = 0; i < strLenght; i++)
        //    {
        //        flagChar = inputText[i];
        //        flag1 = Convert.ToString(inputText[i]);
        //        temp1 = flag1;
        //        if (i == strLenght - 1 && temp == null)                     //taky operator agy access na karain
        //        {                                                    //temp null q k temp ki value zaya na ho
        //            if (flag1 == "\n")
        //            {
        //                BreakWordList.AddBreakPartInList("Return");
        //                continue;
        //            }
        //            BreakWordList.AddBreakPartInList(flag1);
        //            continue;
        //        }


        //        if(flag1=="/" && inputText[i+1]=='/')          //single line comment
        //        {
        //            while(true)
        //            {
        //                i++;
        //                if(inputText[i]=='\n')
        //                {
        //                    BreakWordList.AddBreakPartInList("Return");
        //                    break;
        //                }
        //                if(i>= strLenght-1)
        //                {
        //                    break;
        //                }
        //            }
        //            continue;
        //        }

        //        if(flag1=="/" && inputText[i+1]=='*')         //multiLine Comment
        //        {
        //            i += 2;
        //            while (true)
        //            {

        //                if (i >= strLenght - 1)
        //                {
        //                    break;
        //                }
        //                if(inputText[i]=='\n')
        //                {
        //                    BreakWordList.AddBreakPartInList("Return");
        //                }
        //                if (inputText[i] == '*' && inputText[i+1]=='/')
        //                {
        //                    i++;
        //                    break;
        //                }
        //                i++;

        //            }
        //            continue;
        //        }

        //        if (flag1 == "'")             //char ki kahani
        //        {
        //            if (temp != null)
        //            {
        //                BreakWordList.AddBreakPartInList(temp);
        //                temp = null;
        //            }
        //            while (true)
        //            {

        //                temp = temp + inputText[i];
        //                i++;
        //                if (i >= strLenght)
        //                {
        //                    i--;
        //                    break;

        //                }

        //                string ch = Convert.ToString(inputText[i]);
        //                if (ch == "'")
        //                {
        //                    temp = temp + inputText[i];
        //                    BreakWordList.AddBreakPartInList(temp);
        //                    temp = null;
        //                    break;
        //                }
        //                if (inputText[i] == '\n')
        //                {
        //                    i--;
        //                    BreakWordList.AddBreakPartInList(temp);
        //                    temp = null;
        //                    break;
        //                }

        //            }
        //            continue;

        //        }

        //        if (flagChar == '"')                                        //String ki Kahani mri Zubani
        //        {
        //            if (temp != null)
        //            {
        //                BreakWordList.AddBreakPartInList(temp);
        //                temp = null;
        //            }
        //            while (true)
        //            {
        //                temp = temp + inputText[i];
        //                i++;
        //                if (i >= strLenght - 1)
        //                {
        //                    i--;
        //                    break;
        //                }

        //                if (inputText[i] == '\\')
        //                {
        //                    temp = temp + inputText[i];
        //                    i++;
        //                    if (i >= strLenght - 1)
        //                    {
        //                        i--;
        //                        break;

        //                    }
        //                    temp += inputText[i];
        //                    i++;
        //                }

        //                if (inputText[i] == '"')
        //                {
        //                    temp = temp + inputText[i];
        //                    BreakWordList.AddBreakPartInList(temp);
        //                    temp = null;
        //                    break;
        //                }



        //                if (inputText[i] == '\n')
        //                {
        //                    i--;
        //                    BreakWordList.AddBreakPartInList(temp);
        //                    temp = null;
        //                    break;
        //                }

        //            }
        //            continue;
        //        }

        //        if (flag1 == " " && temp == null)
        //        {
        //            continue;                           // Jab 1 se ziada Space Hun
        //        }

        //        if (CheckBreakCondi(flag1))
        //        {
        //            if ((flag1 == "-" && Convert.ToString(inputText[i + 1]) == ">" ||
        //                flag1 == "+" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "-" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "/" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "*" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "%" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "<" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == ">" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "=" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == "~" && Convert.ToString(inputText[i + 1]) == "=" ||
        //                flag1 == ":" && Convert.ToString(inputText[i + 1]) == ":") && temp == null)
        //            {
        //                i++;
        //                string fla = Convert.ToString(inputText[i]);
        //                flag1 = flag1 + fla;
        //                BreakWordList.AddBreakPartInList(flag1);
        //                continue;
        //            }


        //            if (flag1 == "\n" && temp == null)
        //            {
        //                BreakWordList.AddBreakPartInList("Return");
        //                continue;
        //            }

        //            if (temp == null)
        //            {
        //                BreakWordList.AddBreakPartInList(temp1);
        //                temp1 = null;
        //                continue;
        //            }

        //            BreakWordList.AddBreakPartInList(temp);
        //            temp = null;
        //            if (i != 0)
        //            { i--; }
        //            continue;
        //        }

        //        temp = temp + inputText[i];
        //    }
        //    if (temp != null)
        //        BreakWordList.AddBreakPartInList(temp);
        //}

        //public bool CheckBreakCondi(string s)
        //{

        //    if (s == "\n")
        //    {

        //        i--;
        //        return true;
        //    }

        //    if (s == " ")
        //    {
        //        return true;
        //    }

        //    if (s == "(" || s == ")" || s == "{" || s == "}" || s == "[" || s == "]" ||
        //        s == ";" || s == "," || s == "+" || s == "-" || s == "*" || s == "/" ||
        //        s == "%" || s == "<" || s == "<" || s == "=" || s == "-" ||
        //        s == "?" || s == ":" || s == "~" || s==".")
        //    {
        //        if (i != 0)
        //        {
        //            i--;
        //        }
        //        return true;
        //    }

        //    return false;
        //}
        public void OutNextLine()
        {
            while (CurrentNode123 != null)
            {
                if (CurrentNode123.GetClassPart() == "NEWLINE")
                {
                    if (f)
                    {
                        string cpart = CurrentNode123.GetClassPart();
                        string vpart = CurrentNode123.GetValuePart();
                        int    LNo   = CurrentNode123.GetLineNo();
                        TokenList2.CreateToken(cpart, vpart, LNo);
                        CurrentNode123 = CurrentNode123.GetNextValAdd();
                        f = false;
                    }
                    else
                    {
                        CurrentNode123 = CurrentNode123.GetNextValAdd();
                    }
                }
                else
                {
                    string cpart = CurrentNode123.GetClassPart();
                    string vpart = CurrentNode123.GetValuePart();
                    int    LNo   = CurrentNode123.GetLineNo();
                    TokenList2.CreateToken(cpart, vpart, LNo);
                    CurrentNode123 = CurrentNode123.GetNextValAdd();
                    f = true;
                }
            }
        }
Exemplo n.º 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);
        }