/// <summary>
        /// Resolve undefined function calls by looking in the imported and predefined functions
        /// </summary>
        private void ResolveUndefinedFunctionCalls()
        {
            //Update ChangeParentInfo
            foreach (var fun in Functions)
                fun.Block.UpdateChildrenParentInfo();

            foreach (var ufc in UndefinedFunctionCalls)
                if (ImportedFunctions.ContainsKey(ufc.Key))
                    //Look in the Imported Functions
                {
                    ufc.Value.Update(ImportedFunctions[ufc.Key]);
                    Functions.Add(ImportedFunctions[ufc.Key]);
                }
                else if (PredefinedFunctions.ContainsKey(ufc.Key))
                    //Look in the Predefined Functions
                {
                    var fn = PredefinedFunctions[ufc.Key];
                    foreach (var fc in ufc.Value.Items)
                        if (fc.Arguments.Count != fn.ArgumentsCount)
                            //The signatures must match
                            ThrowParseError("Function " + fn.Name + " takes " + fn.ArgumentsCount + " arguments, not " + fc.Arguments.Count, fc.Annotation.SourcePosition);
                        else
                            //Update valid calls
                        {
                            if (fn == PredefinedFunctions["Match"])
                            {
                                var ts = new TextSearch();
                                ts.Pattern = fc.Arguments[0];
                                ts.Type = TextSearch.eType.Normal;
                                ts.Annotation.CopyFrom(fc.Annotation);
                                ts.Quantifier = fc.Quantifier;
                                AddSourceCodeAnnotation(ts);
                                fc.ChangeInParent(ts);
                            }
                            else if (fn == PredefinedFunctions["Find"])
                            {
                                var ts = new TextSearch();
                                ts.Pattern = fc.Arguments[0];
                                ts.Type = TextSearch.eType.Find;
                                ts.Annotation.CopyFrom(fc.Annotation);
                                ts.Quantifier = fc.Quantifier;
                                AddSourceCodeAnnotation(ts);
                                fc.ChangeInParent(ts);
                            }
                            else if (fn == PredefinedFunctions["FindReverse"])
                            {
                                var ts = new TextSearch();
                                ts.Pattern = fc.Arguments[0];
                                ts.Type = TextSearch.eType.FindReverse;
                                ts.Annotation.CopyFrom(fc.Annotation);
                                ts.Quantifier = fc.Quantifier;
                                AddSourceCodeAnnotation(ts);
                                fc.ChangeInParent(ts);
                            }
                            else if (fn == PredefinedFunctions["Line"])
                            {
                                //Convert to {F"\r\n" Skipped, Source != '' FRE"$" Skipped}
                                var blp = new Block();
                                blp.Annotation.IDE = IDE;
                                blp.Type = Block.eType.Multi;

                                var bl = new Block();
                                bl.Annotation.IDE = IDE;
                                blp.Elements.Add(bl);

                                var ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("\r\n");
                                ts.Type = TextSearch.eType.Find;
                                bl.Elements.Add(ts);

                                var vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Skipped;
                                bl.Elements.Add(vr);

                                bl = new Block();
                                bl.Annotation.IDE = IDE;
                                blp.Elements.Add(bl);

                                var op = new BinaryOperator();
                                op.Annotation.IDE = IDE;
                                op.Type = BinaryOperator.eType.NotEqual;
                                bl.Elements.Add(op);

                                vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Source;
                                op.lhs = vr;

                                var lt = new Literal("");
                                lt.Annotation.IDE = IDE;
                                op.rhs = lt;

                                ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("$");
                                ts.Type = TextSearch.eType.RegularExpression;
                                bl.Elements.Add(ts);

                                vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Skipped;
                                bl.Elements.Add(vr);

                                blp.UpdateChildrenParentInfo();
                                blp.Annotation.CopyFrom(fc.Annotation);
                                blp.Quantifier = fc.Quantifier;
                                AddSourceCodeAnnotation(blp);
                                fc.ChangeInParent(blp);
                            }
                            else if (fn == PredefinedFunctions["Paragraph"])
                            {
                                //Convert to {"\r\n"* F"\r\n\r\n" Skipped & {"\r\n"* ''}, "\r\n"* Source != '' FRE"$" Skipped}
                                var blp = new Block();
                                blp.Annotation.IDE = IDE;
                                blp.Type = Block.eType.Multi;

                                var bl = new Block();
                                bl.Annotation.IDE = IDE;
                                blp.Elements.Add(bl);

                                var ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("\r\n");
                                ts.Type = TextSearch.eType.Normal;
                                ts.Quantifier.Min = 0;
                                ts.Quantifier.Max = -1;
                                bl.Elements.Add(ts);

                                ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("\r\n\r\n");
                                ts.Type = TextSearch.eType.Find;
                                bl.Elements.Add(ts);

                                var op = new BinaryOperator();
                                op.Annotation.IDE = IDE;
                                op.Type = BinaryOperator.eType.TextAppend;
                                bl.Elements.Add(op);

                                var vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Skipped;
                                op.lhs = vr;

                                var bl2 = new Block();
                                bl2.Annotation.IDE = IDE;
                                op.rhs = bl2;

                                ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("\r\n");
                                ts.Type = TextSearch.eType.Normal;
                                ts.Quantifier.Min = 0;
                                ts.Quantifier.Max = -1;
                                bl2.Elements.Add(ts);

                                var lt = new Literal("");
                                lt.Annotation.IDE = IDE;
                                bl2.Elements.Add(lt);

                                bl = new Block();
                                bl.Annotation.IDE = IDE;
                                blp.Elements.Add(bl);

                                ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("\r\n");
                                ts.Type = TextSearch.eType.Normal;
                                ts.Quantifier.Min = 0;
                                ts.Quantifier.Max = -1;
                                bl.Elements.Add(ts);

                                op = new BinaryOperator();
                                op.Annotation.IDE = IDE;
                                op.Type = BinaryOperator.eType.NotEqual;
                                bl.Elements.Add(op);

                                vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Source;
                                op.lhs = vr;

                                lt = new Literal("");
                                lt.Annotation.IDE = IDE;
                                op.rhs = lt;

                                ts = new TextSearch();
                                ts.Annotation.IDE = IDE;
                                ts.Pattern = new Literal("$");
                                ts.Type = TextSearch.eType.RegularExpression;
                                bl.Elements.Add(ts);

                                vr = new Variable();
                                vr.Annotation.IDE = IDE;
                                vr.Type = Variable.eType.Skipped;
                                bl.Elements.Add(vr);

                                blp.UpdateChildrenParentInfo();
                                blp.Annotation.CopyFrom(fc.Annotation);
                                blp.Quantifier = fc.Quantifier;
                                AddSourceCodeAnnotation(blp);
                                fc.ChangeInParent(blp);
                            }
                        }
                }
                else
                    //It is not defined
                    foreach (var fc in ufc.Value.Items)
                        ThrowParseError("'" + fc.Name + "' function not defined", fc.Annotation.SourcePosition);
        }