Example #1
0
        private void ProcessLex(ArrayList leftlex, LexObject midlex, ArrayList rightlex)
        {
            ArrayList LeftItems = new ArrayList();
            int       x         = getNumbers(leftlex);

            if (!midlex.isText)
            {
                TLArray ta = (TLArray)Arrays[midlex.pointer];
                x *= ta.content.Count;
            }
            for (int i = 0; i < leftlex.Count; i++)
            {
                LeftItems.Add(GenerateLex((LexObject)leftlex[i], x, i, leftlex));
            }
            ArrayList MidItems = new ArrayList();

            if (midlex.isText)
            {
                for (int i = 0; i < x; i++)
                {
                    if (midlex.pointer == 98761197)
                    {
                        MidItems.Add("delete");
                    }
                    else
                    {
                        MidItems.Add(midlex.text);
                    }
                }
            }
            else
            {
                int     h  = 0;
                TLArray tl = (TLArray)Arrays[midlex.pointer];
                while (MidItems.Count < x)
                {
                    MidItems.Add(tl.content[h]);
                    h++;
                    if (h == tl.content.Count)
                    {
                        h = 0;
                    }
                }
            }
            ArrayList RightItems = new ArrayList();

            for (int i = 0; i < rightlex.Count; i++)
            {
                RightItems.Add(DereferenceLeft((LexObject)rightlex[i], x, LeftItems, leftlex, (LexObject)rightlex[i], MidItems, midlex));
            }
            for (int i = 0; i < x; i++)
            {
                string left  = "";
                string right = "";
                for (int j = 0; j < LeftItems.Count; j++)
                {
                    left += ((ArrayList)LeftItems[j])[i].ToString();
                }
                for (int j = 0; j < RightItems.Count; j++)
                {
                    right += ((ArrayList)RightItems[j])[i].ToString();
                }
                ENI.Add(left);
                Lines.Add(line.ToString());
                ENM.Add(MidItems[i]);
                ENO.Add(right);
            }
        }
Example #2
0
        private string ProcessNoContext(string currentline)
        {
            string left   = "";
            string right  = "";
            string temp   = "";
            int    state  = 0;
            bool   isleft = true;

            foreach (char c in currentline.ToCharArray())
            {
                switch (state)
                {
                case 0:
                    if (c == '\'')
                    {
                        state = 1;
                    }
                    else if (c == 'U')
                    {
                        state = 3;
                    }
                    else if (c == ' ' || c == '\t')
                    {
                    }
                    else if (c == '>')
                    {
                        isleft = false;
                    }
                    else if (c == '#')
                    {
                        state = 5;
                    }
                    else
                    {
                        return("Invalid Character - " + c);
                    }
                    break;

                case 1:
                    if (c == '\\')
                    {
                        state = 2;
                    }
                    else if (c == '\'')
                    {
                        state = 0;
                    }
                    else
                    {
                        if (isleft)
                        {
                            left += c;
                        }
                        else
                        {
                            right += c;
                        }
                    }
                    break;

                case 2:
                    if (c == '\\')
                    {
                        if (isleft)
                        {
                            left += c;
                        }
                        else
                        {
                            right += c;
                        }
                    }
                    else if (c == '\'')
                    {
                        if (isleft)
                        {
                            left += c;
                        }
                        else
                        {
                            right += c;
                        }
                    }
                    else
                    {
                        return("Invalid Escape Character - " + c);
                    }
                    state = 1;
                    break;

                case 3:
                    if (c == '+')
                    {
                        state = 4;
                    }
                    else
                    {
                        return("Invalid Unicode Point");
                    }
                    break;

                case 4:
                    if (checkHex(c))
                    {
                        temp += c;
                    }
                    else if (c == ' ' || c == '\t')
                    {
                        if (temp.Length == 4)
                        {
                            int i = Convert.ToInt32(temp, 16);
                            if (isleft)
                            {
                                left += (char)i;
                            }
                            else
                            {
                                right += (char)i;
                            }
                            temp  = "";
                            state = 0;
                        }
                        else
                        {
                            return("Invalid Unicode Point");
                        }
                    }
                    else
                    {
                        return("Invalid Unicode Point");
                    }
                    break;

                case 5:
                    if (c == '#')
                    {
                        state = 6;
                    }
                    else
                    {
                        return("Invalid Character - #");
                    }
                    break;

                case 6:
                    break;
                }
            }
            if (state != 0 && state != 6)
            {
                if (state == 4 && isleft == false)
                {
                    int i = Convert.ToInt32(temp, 16);
                    right += (char)i;
                    temp   = "";
                    state  = 0;
                }
                else
                {
                    return("Error in End of Line");
                }
            }

            ENI.Add(left);
            ENO.Add(right);
            return("OK");
        }