예제 #1
0
        //Element elem_val;//Если тип переменной - Element
        //может номер в новой таблице, которая в webBrowser?
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="lex">лексема</param>
        /// <param name="elem">значение HtmlElement</param>
        /// <param name="collect">значение HtmlElementCollection</param>
        public LexID(Lexem lex, HtmlElement elem = null, List <HtmlElement> collect = null)
        {
            html_elem         = elem;
            html_elem_collect = collect;//Не копирование, а просто присваивание ссылки
            value             = "";
            name = lex.getName();

            if (elem != null)
            {
                type  = Type_of_lex._htmlelement;
                value = name;
            }
            else if (collect != null)
            {
                type  = Type_of_lex._htmlelementcollect;
                value = name;
            }
            else if (lex.get_type() != Type_of_lex.LEX_id)
            {
                type = lex.get_type();
            }
            else
            {
                type = Type_of_lex._undefined;
            }
        }
예제 #2
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="lex">Лексема-идентификатор</param>
 public LexID(LexID lex)
 {
     name              = lex.name;
     type              = lex.type;
     value             = lex.value;
     html_elem         = lex.html_elem;
     html_elem_collect = lex.html_elem_collect;
 }
예제 #3
0
 public void putType(Type_of_lex val)
 {
     type = val;
     if (type == Type_of_lex._htmlelement || type == Type_of_lex._htmlelementcollect)
     {
         value = name;
     }
 }
예제 #4
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="name">Имя функции</param>
 public TableIDinFunction(string name)
 {
     st_lex     = new Stack <Type_of_lex>();
     tId        = new List <LexID>();
     curId      = -1;
     has_event  = false;
     funcName   = name;
     returnType = Type_of_lex._undefined;
 }
예제 #5
0
 public void putTypeOfLex(Lexem lex, Type_of_lex type)
 {
     for (int i = 0; i < tId.Count; i++)
     {
         if (tId[i].getName() == lex.getName())
         {
             tId[i].putType(type);
         }
     }
 }
예제 #6
0
 public void putTypeOfLex(string name, Type_of_lex type)
 {
     for (int i = 0; i < tId.Count; i++)
     {
         if (tId[i].getName() == name)
         {
             tId[i].putType(type);
         }
     }
 }
예제 #7
0
        string add_new_uniq_lexId(Type_of_lex type, HtmlElement elem, List <HtmlElement> collect)
        {
            string name = "/hlp_iter_var";

            while (tableId.getNumOfLex(name) != -1)
            {
                name += "/";
            }
            tableId.addId(new LexID(new Lexem(type, name), elem, collect));
            return(name);
        }
예제 #8
0
        public bool check_op()
        {
            Type_of_lex t1, op, t2, type = Type_of_lex._undefined;

            t2 = funcIdTable[curFunc].pop();
            op = funcIdTable[curFunc].pop();
            t1 = funcIdTable[curFunc].pop();
            if (t1 == Type_of_lex._htmlelement || t1 == Type_of_lex._htmlelementcollect ||
                t2 == Type_of_lex._htmlelement || t2 == Type_of_lex._htmlelementcollect)
            {
                return(false);
            }
            if ((op == Type_of_lex.LEX_plus) || (op == Type_of_lex.LEX_minus) || (op == Type_of_lex.LEX_mul) || (op == Type_of_lex.LEX_slash))
            {
                type = t1;
            }
            else if ((op == Type_of_lex.LEX_or) || (op == Type_of_lex.LEX_and) || (op == Type_of_lex.LEX_eq) || (op == Type_of_lex.LEX_neq) ||
                     (op == Type_of_lex.LEX_bigger) || (op == Type_of_lex.LEX_biggerEq) || (op == Type_of_lex.LEX_less) ||
                     (op == Type_of_lex.LEX_lessEq))
            {
                type = Type_of_lex._bool;
            }
            //prog.put_lex(new Lexem(t1));
            poliz_put_lex(new Lexem(op));
            //prog.put_lex(new Lexem(t2));
            string nameId;

            if (t1 == t2)
            {
                //if (t1 != Type_of_lex._undefined) {
                funcIdTable[curFunc].push(type);
                return(true);
                //}
            }
            else if (t1 == Type_of_lex._undefined)
            {
                funcIdTable[curFunc].push(t2);
                nameId = poliz_get_num_of_id(poliz_get_free() - 3);
                funcIdTable[curFunc].putTypeOfLex(nameId, t2);
                return(true);
            }
            else if (t2 == Type_of_lex._undefined)
            {
                funcIdTable[curFunc].push(t1);
                nameId = poliz_get_num_of_id(poliz_get_free() - 2);
                funcIdTable[curFunc].putTypeOfLex(nameId, t1);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #9
0
        public bool checkId(Lexem lex)
        {
            if (funcIdTable[curFunc].isDeclare(lex))
            {
                int         num  = funcIdTable[curFunc].getNumOfLex(lex.getName());
                Type_of_lex type = funcIdTable[curFunc].getTypeOfLex(lex.getName());

                funcIdTable[curFunc].push(type);
                return(true);
            }
            else if (isFuncDeclare(lex.getName()))
            {
                Type_of_lex type = getTypeOfFunc(lex.getName());
                funcIdTable[curFunc].push(type);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
 public void putValOfLex(int i, string val, bool isHtml = false)
 {
     if (!isHtml)
     {
         tId[i].putValue(val);
     }
     else
     {
         int                num  = getNumOfLex(val);
         Type_of_lex        type = getTypeOfLex(num);
         HtmlElement        elem;
         List <HtmlElement> elem_collect;
         if (type == Type_of_lex._htmlelement)
         {
             elem = tId[num].get_htmlElem_val();
             tId[i].put_html_val(elem);
         }
         else
         {
             elem_collect = tId[num].get_htmlElemCollection_val();
             tId[i].put_html_val(elem_collect);
         }
     }
 }
예제 #11
0
 public void putTypeOfLex(int num, Type_of_lex type)
 {
     tId[num].putType(type);
 }
예제 #12
0
 void putTypeofLex(int num, Type_of_lex type)
 {
     tableId.putTypeofLex(num, type);
 }
예제 #13
0
 //------------------------------
 //обертка для TableIDinFunction
 //public void initialize_all_vars() {
 //    funcIdTable[curFunc].initialize_all_vars();
 //}
 public void putTypeOfFunc(Type_of_lex type)
 {
     funcIdTable[curFunc].putTypeOfFunc(type);
 }
예제 #14
0
 string name;//оно же значение
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="t">Тип лексемы</param>
 /// <param name="v">Значение лексемы(имя)</param>
 public Lexem(Type_of_lex t = Type_of_lex.LEX_NULL, string v = "")
 {
     t_lex = t;
     name  = v;
 }
예제 #15
0
 /// <summary>
 /// Получает тип лексемы
 /// </summary>
 /// <param name="type"></param>
 public void put_type(Type_of_lex type)
 {
     t_lex = type;
 }
예제 #16
0
 public void push(Type_of_lex type)
 {
     st_lex.Push(type);
 }
예제 #17
0
 public void putTypeOfFunc(Type_of_lex type)
 {
     returnType = type;
 }
예제 #18
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="lex">Инициализирует экземпляр класса существующей лексемой</param>
 public Lexem(Lexem lex)
 {
     t_lex = lex.get_type();
     name  = lex.getName();
 }
예제 #19
0
        /// <summary>
        /// Реализует выполнение описанных пользователем функций
        /// </summary>
        /// <param name="func_name"></param>
        public void run_func(string func_name)
        {
            int                old_curFunc = tableId.get_curFunc();
            int                num_of_func = tableId.getNumOfFunc(func_name);
            int                num_params  = tableId.get_num_of_param(func_name);
            int                old_csp     = cur_step_poliz;
            HtmlElement        helem;
            List <HtmlElement> helemCollect, collect_to_run_func;

            Lexem[] lex_arr = new Lexem[num_params];
            //в массиве лежат либо константы, либо переменные

            //создать новый экземпляр класса executer и вызвать из него выполнение проги
            setCurFunc(num_of_func);
            //Да, ничего не скопирует, но рекурсия станет возможной
            Executer func_exec = new Executer(tableId, in_stream, out_stream, wb);

            //передача параметров в вызываемую функцию
            for (int i = num_params - 1; i >= 0; i--)
            {
                lex_arr[i] = args.Pop();
            }
            //обнуление всех переменных внутри функции
            //func_exec.tableId.initialize_all_vars();
            for (int i = 0; i < num_params; i++)
            {
                if (lex_arr[i].get_type() == Type_of_lex._htmlelement || lex_arr[i].get_type() == Type_of_lex._htmlelementcollect)
                {
                    //func_exec.tableId.putValueOfLex(i, lex_arr[i].getName(), true);
                    setCurFunc(old_curFunc);
                    if (lex_arr[i].get_type() == Type_of_lex._htmlelement)
                    {
                        helem = func_exec.tableId.get_htmlElem_of_lex(lex_arr[i].getName());
                        setCurFunc(num_of_func);
                        func_exec.tableId.putHtmlElemValueOfLex(i, helem);
                    }
                    else
                    {
                        helemCollect = tableId.get_htmlElemCollect_of_lex(lex_arr[i].getName());
                        setCurFunc(num_of_func);

                        collect_to_run_func = new List <HtmlElement>(helemCollect.Count);
                        for (int j = 0; j < helemCollect.Count; j++)
                        {
                            collect_to_run_func.Add(helemCollect[j]);
                        }
                        //тут нужно передать не ссылку, а новый список
                        func_exec.tableId.putHtmlElemCollectValueOfLex(i, collect_to_run_func);
                    }
                }
                else
                {
                    func_exec.tableId.putValueOfLex(i, lex_arr[i].getName());
                }
                if (lex_arr[i].get_type() != Type_of_lex._undefined)
                {
                    func_exec.putTypeofLex(i, lex_arr[i].get_type());
                }
            }
            func_exec.execute();
            Lexem lex = null;

            if (func_exec.args.Count > 0)
            {
                lex = func_exec.args_pop();
            }

            //для добавления вспомогательной переменной
            if (lex != null)
            {
                Type_of_lex type = tableId.getTypeOfFunc(func_name);
                if (type == Type_of_lex._htmlelement || type == Type_of_lex._htmlelementcollect)
                {
                    string             res_name        = "";
                    HtmlElement        htmlElem        = null;
                    List <HtmlElement> htmlElemCollect = null;
                    if (type == Type_of_lex._htmlelement)
                    {
                        htmlElem        = tableId.get_htmlElem_of_lex(lex.getName());
                        htmlElemCollect = null;
                    }
                    else
                    {
                        htmlElemCollect = tableId.get_htmlElemCollect_of_lex(lex.getName());
                        htmlElem        = null;
                    }
                    setCurFunc(old_curFunc);
                    res_name = add_new_uniq_lexId(type, htmlElem, htmlElemCollect);
                    lex.putName(res_name);
                }
                args.Push(lex);
            }
            setCurFunc(old_curFunc);
            cur_step_poliz = old_csp;
        }
예제 #20
0
 void putTypeOfFunc(Type_of_lex type)
 {
     tableId.putTypeOfFunc(type);
 }
예제 #21
0
 public void putTypeofLex(int num, Type_of_lex type)
 {
     funcIdTable[curFunc].putTypeOfLex(num, type);
 }
예제 #22
0
        /// <summary>
        /// Реализует выполнение встроенных функций
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool run_inet_func(string name)
        {
            HtmlElement        htmlElem      = null;
            List <HtmlElement> htmlElem_list = null;
            string             res           = "";
            bool bl;

            int num_params = tableId.get_num_of_param(name);

            Lexem[] lex_arr = new Lexem[num_params];
            //в массиве лежат либо константы, либо переменные

            for (int i = num_params - 1; i >= 0; i--)
            {
                lex_arr[i] = args.Pop();
            }

            //switch по функциям
            switch (name)
            {
            case "click_by_id":
                wb.click_by_id(lex_arr[0].getName());
                break;

            case "check_by_id":
                bl  = wb.check_by_id(lex_arr[0].getName());
                res = getValueFromBool(bl);
                break;

            case "input_by_id":
                wb.input_by_id(lex_arr[0].getName(), lex_arr[1].getName());
                break;

            case "go":
                wb.go(lex_arr[0].getName());
                break;

            case "check_by_text":
                bl  = wb.check_by_text(lex_arr[0].getName());
                res = getValueFromBool(bl);
                break;

            case "set_options":
                wb.set_options(lex_arr[0].getName());
                break;

            case "click_href":
                wb.click_href(lex_arr[0].getName());
                break;

            case "click_by_text":
                wb.click_by_text(lex_arr[0].getName());
                break;

            case "set_check_box_flag":
                wb.set_check_box_flag(lex_arr[0].getName(), getBoolFromValue(lex_arr[1]));
                break;

            case "click_check_box_flag":
                wb.click_check_box_flag(lex_arr[0].getName());
                break;

            case "click_elem":
                wb.click_elem(tableId.get_htmlElem_of_lex(lex_arr[0].getName()));
                break;

            //----------------------
            case "get_tree":
                htmlElem_list = wb.get_tree(lex_arr[0].getName());
                break;

            case "get_elements_by_tag":
                htmlElem_list = wb.get_elements_by_tag(lex_arr[0].getName());
                break;

            case "get_elements_by_attr_value":
                htmlElem_list = wb.get_elements_by_attr_value(lex_arr[0].getName(), lex_arr[1].getName());

                break;

            case "save":
                htmlElem = tableId.get_htmlElem_of_lex(lex_arr[0].getName());
                //res = wb.save(htmlElem, lex_arr[1].getName());
                wb.save(htmlElem, lex_arr[1].getName());
                break;

            case "saveHTML":
                htmlElem = tableId.get_htmlElem_of_lex(lex_arr[0].getName());
                //res = wb.saveHTML(htmlElem, lex_arr[1].getName());
                wb.saveHTML(htmlElem, lex_arr[1].getName());
                break;

            case "save_images":
                htmlElem = tableId.get_htmlElem_of_lex(lex_arr[0].getName());
                wb.save_images(htmlElem, lex_arr[0].getName());
                break;

            //-------------------------
            case "get_element_with_num":
                htmlElem = tableId.get_htmlElemCollect_of_lex(lex_arr[0].getName())[Convert.ToInt32(lex_arr[1].getName())];
                break;

            case "get_length":
                res = tableId.get_htmlElemCollect_of_lex(lex_arr[0].getName()).Count.ToString();
                break;

            case "input_elem":
                wb.input_elem(tableId.get_htmlElem_of_lex(lex_arr[0].getName()), lex_arr[1].getName());
                break;

            case "set_check_box_elem":
                wb.set_check_box_elem(tableId.get_htmlElem_of_lex(lex_arr[0].getName()), getBoolFromValue(lex_arr[1]));
                break;

            case "set_options_elem":
                wb.set_options_elem(tableId.get_htmlElem_of_lex(lex_arr[0].getName()), lex_arr[1].getName());
                break;

            case "wait":
                wb.wait(Convert.ToInt32(lex_arr[0].getName()));
                break;

            case "go_back":
                wb.go_back();
                break;

            default:
                break;
            }
            Type_of_lex type = tableId.getTypeOfFunc(name);

            if (type != Type_of_lex._void)
            {
                if (type == Type_of_lex._htmlelement || type == Type_of_lex._htmlelementcollect)
                {
                    res = add_new_uniq_lexId(type, htmlElem, htmlElem_list);
                }
                args.Push(new Lexem(type, res));
            }
            //cur_step_poliz++;
            return(tableId.get_has_event_func(name));
        }