Esempio n. 1
0
 /// <summary>
 /// Создать цикл while
 /// </summary>
 /// <param name="condition">Условие цикла</param>
 /// <param name="body">Тело цикла</param>
 /// <returns></returns>
 public SyntaxTree.while_node CreateWhile(expression condition, statement body)
 {
     SyntaxTree.while_node res = new SyntaxTree.while_node();
     res.CycleType = WhileCycleType.While;
     res.expr = condition;
     res.statements = body;
     return res;
 }
Esempio n. 2
0
 /// <summary>
 /// Создать цикл for
 /// </summary>
 /// <param name="varName">Имя переменной цикла</param>
 /// <param name="initValue">Начальное значение переменной цикла</param>
 /// <param name="finishValue">Конечное значение переменной цикла</param>
 /// <param name="body">Тело цикла</param>
 /// <param name="type">Тип цикла(to / downto)</param>
 /// <returns></returns>
 public SyntaxTree.for_node CreateFor(string varName, expression initValue, expression finishValue, statement body, for_cycle_type type)
 {
     SyntaxTree.for_node res = new SyntaxTree.for_node();
     res.loop_variable = new ident(varName);
     res.initial_value = initValue;
     res.finish_value = finishValue;
     res.statements = body;
     res.cycle_type = type;
     return res;
 }
		public void write_statement(statement _statement)
		{
			write_declaration(_statement);
		}
Esempio n. 4
0
 public for_node NewForStmt(bool opt_var, ident identifier, type_definition for_stmt_decl_or_assign, expression expr1, for_cycle_type fc_type, expression expr2, token_info opt_tk_do, statement stmt, LexLocation loc)
 {
     var nfs = new for_node(identifier, expr1, expr2, stmt, fc_type, null, for_stmt_decl_or_assign, opt_var != false, loc); 
     if (opt_tk_do == null)
     {
         file_position fp = expr2.source_context.end_position;
         syntax_tree_node err_stn = stmt;
         if (err_stn == null)
             err_stn = expr2;
         parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKDO"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn));
     }
     return nfs;
 }
Esempio n. 5
0
        public static procedure_definition BuildShortProcFuncDefinitionNoSC(procedure_header header, statement st)
        {
            var stlist = new statement_list(st, st.source_context);
            var b = new block(null, stlist, st.source_context);

            return new procedure_definition(header, b, true, BuildGenSC);
        }
 public void Process(statement st)
 {
     if (st is yield_node)
     {
         var yn = st as yield_node;
         curState += 1;
         res.AddMany(
             new assign(YieldConsts.Current, yn.ex, yn.source_context),
             new assign(YieldConsts.State, curState),
             new assign("Result", true),
             new procedure_call("exit"),
             new labeled_statement(YieldConsts.LabelStatePrefix+curState.ToString())
         );
     }
     else if (st is labeled_statement)
     {
         var ls = st as labeled_statement;
         res.Add(new labeled_statement(ls.label_name));
         Process(ls.to_statement);
     }
     else
     {
         res.Add(st);
     }
 }
Esempio n. 7
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public with_statement(statement _what_do,expression_list _do_with)
		{
			this._what_do=_what_do;
			this._do_with=_do_with;
		}
Esempio n. 8
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public labeled_statement(ident _label_name,statement _to_statement)
		{
			this._label_name=_label_name;
			this._to_statement=_to_statement;
		}
Esempio n. 9
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public repeat_node(statement _statements,expression _expr)
		{
			this._statements=_statements;
			this._expr=_expr;
		}
Esempio n. 10
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public for_node(ident _loop_variable,expression _initial_value,expression _finish_value,statement _statements,for_cycle_type _cycle_type,expression _increment_value,type_definition _type_name,bool _create_loop_variable,SourceContext sc)
		{
			this._loop_variable=_loop_variable;
			this._initial_value=_initial_value;
			this._finish_value=_finish_value;
			this._statements=_statements;
			this._cycle_type=_cycle_type;
			this._increment_value=_increment_value;
			this._type_name=_type_name;
			this._create_loop_variable=_create_loop_variable;
			source_context = sc;
		}
Esempio n. 11
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public function_lambda_definition(ident_list _ident_list,type_definition _return_type,formal_parameters _formal_parameters,statement _proc_body,procedure_definition _proc_definition,expression_list _parameters,string _lambda_name,List<declaration> _defs,LambdaVisitMode _lambda_visit_mode,syntax_tree_node _substituting_node,SourceContext sc)
		{
			this._ident_list=_ident_list;
			this._return_type=_return_type;
			this._formal_parameters=_formal_parameters;
			this._proc_body=_proc_body;
			this._proc_definition=_proc_definition;
			this._parameters=_parameters;
			this._lambda_name=_lambda_name;
			this._defs=_defs;
			this._lambda_visit_mode=_lambda_visit_mode;
			this._substituting_node=_substituting_node;
			source_context = sc;
		}
Esempio n. 12
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public lock_stmt(expression _lock_object,statement _stmt,SourceContext sc)
		{
			this._lock_object=_lock_object;
			this._stmt=_stmt;
			source_context = sc;
		}
Esempio n. 13
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public lock_stmt(expression _lock_object,statement _stmt)
		{
			this._lock_object=_lock_object;
			this._stmt=_stmt;
		}
Esempio n. 14
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public switch_stmt(expression _condition,statement _stmt,SwitchPartType _Part,SourceContext sc)
		{
			this._condition=_condition;
			this._stmt=_stmt;
			this._Part=_Part;
			source_context = sc;
		}
Esempio n. 15
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public switch_stmt(expression _condition,statement _stmt,SwitchPartType _Part)
		{
			this._condition=_condition;
			this._stmt=_stmt;
			this._Part=_Part;
		}
Esempio n. 16
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public case_node(expression _param,case_variants _conditions,statement _else_statement)
		{
			this._param=_param;
			this._conditions=_conditions;
			this._else_statement=_else_statement;
		}
Esempio n. 17
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public case_node(expression _param,case_variants _conditions,statement _else_statement,SourceContext sc)
		{
			this._param=_param;
			this._conditions=_conditions;
			this._else_statement=_else_statement;
			source_context = sc;
		}
Esempio n. 18
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public repeat_node(statement _statements,expression _expr,SourceContext sc)
		{
			this._statements=_statements;
			this._expr=_expr;
			source_context = sc;
		}
Esempio n. 19
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public labeled_statement(ident _label_name,statement _to_statement,SourceContext sc)
		{
			this._label_name=_label_name;
			this._to_statement=_to_statement;
			source_context = sc;
		}
Esempio n. 20
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public while_node(expression _expr,statement _statements,WhileCycleType _CycleType)
		{
			this._expr=_expr;
			this._statements=_statements;
			this._CycleType=_CycleType;
		}
Esempio n. 21
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public with_statement(statement _what_do,expression_list _do_with,SourceContext sc)
		{
			this._what_do=_what_do;
			this._do_with=_do_with;
			source_context = sc;
		}
Esempio n. 22
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public while_node(expression _expr,statement _statements,WhileCycleType _CycleType,SourceContext sc)
		{
			this._expr=_expr;
			this._statements=_statements;
			this._CycleType=_CycleType;
			source_context = sc;
		}
Esempio n. 23
0
 public static procedure_definition BuildShortProcDefinition(formal_parameters fp, procedure_attributes_list att, method_name name, statement st, SourceContext headsc)
 {
     var ff = new procedure_header(fp, att, name, null, headsc);
     return BuildShortProcFuncDefinition(ff, st);
 }
Esempio n. 24
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public if_node(expression _condition,statement _then_body,statement _else_body)
		{
			this._condition=_condition;
			this._then_body=_then_body;
			this._else_body=_else_body;
		}
Esempio n. 25
0
        public while_node NewWhileStmt(token_info tkWhile, expression expr, token_info opt_tk_do, statement stmt, LexLocation loc)
        {
            var nws = new while_node(expr, stmt, WhileCycleType.While, loc); 
			if (opt_tk_do == null)
			{
				file_position fp = expr.source_context.end_position;
				syntax_tree_node err_stn = stmt;
				if (err_stn == null)
					err_stn = expr;
                parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKDO"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn));
			}
            return nws;
        }
Esempio n. 26
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public if_node(expression _condition,statement _then_body,statement _else_body,SourceContext sc)
		{
			this._condition=_condition;
			this._then_body=_then_body;
			this._else_body=_else_body;
			source_context = sc;
		}
		public void visit(statement _statement)
		{
			bw.Write((Int16)2);
			write_statement(_statement);
		}
Esempio n. 28
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public case_variant(expression_list _conditions,statement _exec_if_true)
		{
			this._conditions=_conditions;
			this._exec_if_true=_exec_if_true;
		}
        public void Process(statement st)
        {
            if (!(st is yield_node || st is labeled_statement))
            {
                curStatList.Add(st);
            }
            if (st is yield_node)
            {
                var yn = st as yield_node;
                curState += 1;
                curStatList.AddMany(
                    new assign(Consts.Current, yn.ex),
                    new assign(Consts.State, curState),
                    new assign("Result", true),
                    new procedure_call("exit")
                );

                curStatList = new statement_list();
                case_variant cv = new case_variant(new expression_list(new int32_const(curState)), curStatList);
                cas.conditions.variants.Add(cv);
            }
            if (st is labeled_statement)
            {
                var ls = st as labeled_statement;
                curStatList = StatListAfterCase;
                curStatList.Add(new labeled_statement(ls.label_name));
                Process(ls.to_statement);
            }
        }
Esempio n. 30
0
		///<summary>
		///Конструктор с параметрами.
		///</summary>
		public case_variant(expression_list _conditions,statement _exec_if_true,SourceContext sc)
		{
			this._conditions=_conditions;
			this._exec_if_true=_exec_if_true;
			source_context = sc;
		}