private BaseAst CheckFunctionCallsInIfAST(ProgramAst program, IfAst cmd)
        {
            BaseAst err = CheckFunctionCallsInStatementAST(program, cmd.IfBody);

            if ((err != null) && (err.Token != TokenTypes.End) && (err.IsError))
            {
                return(err);
            }
            return(CheckFunctionCallsInStatementAST(program, cmd.ElseBody));
        }
        private void WriteIf(IfAst ast, List<string> vars, string p, bool writeLE)
        {
            file.WriteLine("{0}if ({1})", p, GetExpr(ast.Condition));
            if (writeLE)
                WriteLinearEquations(ast.ConvertCondition.Node, vars, p);

            WriteBody(ast.IfBody, vars, p, writeLE);

            if (ast.ElseBody != null)
            {
                file.WriteLine("{0}else", p);
                WriteBody(ast.ElseBody, vars, p, writeLE);
                if (writeLE)
                    WriteLinearEquations(ast.ConvertElseEndBody.Node, vars, p);
            }
            else if (writeLE)
            {
                WriteLinearEquations(ast.ConvertIfEndBody.Node, vars, p);

            }
        }
        private BaseAst GetIfAST(IfAst cmd)
        {
            if (cmd == null)
            {
                return(BaseAst.GetErrorAstNode("Chybne volana funkce 'GetIfAST(IfAst cmd)', parametr 'cmd' je null"));
            }

            BaseAst cond;
            BaseAst tmp = GetCondAST(out cond);

            if (tmp.IsError)
            {
                return(tmp);
            }
            cmd.Condition = cond;

            BaseAst block = StatementOrBlock();

            if (block.IsError)
            {
                return(block);
            }
            cmd.IfBody = block;

            if (nextNode.Token == TokenTypes.ElseRW)
            {
                ReadNextAst();
                block = StatementOrBlock();
                if (block.IsError)
                {
                    return(block);
                }
                cmd.ElseBody = block;
            }

            return(cmd);
        }
        private IEnumerable <BaseAst> ConvertIf(IfAst node)
        {
            List <BaseAst> block = new List <BaseAst>();

            internalLabelIdx++;
            int idx = internalLabelIdx;

            block.Add(new BaseAst {
                Token = TokenTypes.Identifier, AstType = AstNodeTypes.Label, TokenText = string.Format("$IfBegin{0}", idx)
            });

            ConditionAst cond = ConvertTo <ConditionAst>(node, AstNodeTypes.Condition);

            cond.Condition = NegateCondition(node.Condition);
            block.Add(cond);
            node.ConvertCondition = cond;

            if (node.ElseBody != null)
            {
                block.Add(new GotoAst {
                    Token = TokenTypes.GotoRW, AstType = AstNodeTypes.Goto, TokenText = "goto", Label = string.Format("$IfFalse{0}", idx)
                });
            }
            else
            {
                block.Add(new GotoAst {
                    Token = TokenTypes.GotoRW, AstType = AstNodeTypes.Goto, TokenText = "goto", Label = string.Format("$IfEnd{0}", idx)
                });
            }

            block.Add(new BaseAst {
                Token = TokenTypes.Identifier, AstType = AstNodeTypes.Label, TokenText = string.Format("$IfTrue{0}", idx)
            });
            block.AddRange(ConvertStatement(node.IfBody));

            GotoAst gt = new GotoAst {
                Token = TokenTypes.GotoRW, AstType = AstNodeTypes.Goto, TokenText = "goto", Label = string.Format("$IfEnd{0}", idx)
            };

            block.Add(gt);
            node.ConvertIfEndBody = gt;

            if (node.ElseBody != null)
            {
                block.Add(new BaseAst {
                    Token = TokenTypes.Identifier, AstType = AstNodeTypes.Label, TokenText = string.Format("$IfFalse{0}", idx)
                });
                block.AddRange(ConvertStatement(node.ElseBody));

                gt = new GotoAst {
                    Token = TokenTypes.GotoRW, AstType = AstNodeTypes.Goto, TokenText = "goto", Label = string.Format("$IfEnd{0}", idx)
                };
                block.Add(gt);
                node.ConvertElseEndBody = gt;
            }

            block.Add(new BaseAst {
                Token = TokenTypes.Identifier, AstType = AstNodeTypes.Label, TokenText = string.Format("$IfEnd{0}", idx)
            });

            return(block);
        }