private void AddNodesToAST(List <SnapshotNode> nodesToAdd)
        {
            foreach (SnapshotNode node in nodesToAdd)
            {
                switch (node.Type)
                {
                case SnapshotNodeType.Identifier: gc.CreateIdentifierNode(node.Id, node.Content); break;

                case SnapshotNodeType.Literal:

                    // TODO Jun: This may have to be removed and just moved to the contion where CodeBlocks are processed
                    object parameter1  = null;
                    string caption1    = node.Content;
                    int    intResult1  = 0;
                    bool   boolResult1 = false;
                    double dblResult1  = 0;
                    if (Int32.TryParse(caption1, out intResult1))
                    {
                        parameter1 = intResult1;
                    }
                    else if (Double.TryParse(caption1, out dblResult1))
                    {
                        parameter1 = dblResult1;
                    }
                    else if (Boolean.TryParse(caption1, out boolResult1))
                    {
                        parameter1 = boolResult1;
                    }
                    else
                    {
                        parameter1 = caption1;
                    }
                    gc.CreateLiteralNode(node.Id, parameter1);
                    break;

                case SnapshotNodeType.Function:
                    string[] functionQualifers = node.Content.Split(';');
                    int      funcargs          = 0;
                    string[] argtypes          = functionQualifers[2].Split(',');
                    if (!string.IsNullOrEmpty(functionQualifers[2]))
                    {
                        funcargs = argtypes.Length;
                    }
                    switch (functionQualifers[1])
                    {
                    case "+":
                    case "-":
                    case "*":
                    case "/":
                    case "%":
                    case "==":
                    case "!=":
                    case ">=":
                    case ">":
                    case "<=":
                    case "<":
                    case "&&":
                    case "||":
                    case "&":
                    case "|":
                    case "^": if (functionQualifers.Length < 5)
                        {
                            gc.CreateOperatorNode(node.Id, functionQualifers[1], functionQualifers[3]);
                        }
                        else
                        {
                            gc.CreateOperatorNode(node.Id, functionQualifers[1], functionQualifers[3], functionQualifers[4]);
                        }
                        break;

                    // Cooresponding to DSS.Graph.Core/Resoueces/library.xml
                    case "Range.ByIntervals":
                        if (functionQualifers.Length < 5)
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 2, functionQualifers[3]);
                        }
                        else
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 2, functionQualifers[3], functionQualifers[4]);
                        } break;

                    case "Range.ByIncrementValue":
                        if (functionQualifers.Length < 5)
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 0, functionQualifers[3]);
                        }
                        else
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 0, functionQualifers[3], functionQualifers[4]);
                        } break;

                    case "Range.ByApproximateIncrementValue":
                        if (functionQualifers.Length < 5)
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 1, functionQualifers[3]);
                        }
                        else
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 1, functionQualifers[3], functionQualifers[4]);
                        } break;

                    case "Range":
                        if (functionQualifers.Length < 5)
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 1, functionQualifers[3]);
                        }
                        else
                        {
                            gc.CreateRangeNode(node.Id, functionQualifers[1], funcargs, 1, functionQualifers[3], functionQualifers[4]);
                        } break;

                    default: if (functionQualifers.Length < 5)
                        {
                            if (!(functionQualifers[0]).Equals("Built-in Functions"))
                            {
                                CreateImportNodeIfRequired(functionQualifers[0]);
                            }
                            gc.CreateFunctionNode(node.Id, functionQualifers[1], funcargs, functionQualifers[3]);
                        }
                        else
                        {
                            if (!(functionQualifers[0]).Equals("Built-in Functions"))
                            {
                                //if (functionQualifers[0].Contains(@":\"))
                                //    functionQualifers[0] = GraphUtilities.ConvertAbsoluteToRelative(functionQualifers[0]);
                                CreateImportNodeIfRequired(functionQualifers[0]);
                            }
                            gc.CreateFunctionNode(node.Id, functionQualifers[1], funcargs, functionQualifers[3], functionQualifers[4]);
                        } break;
                    }
                    break;

                case SnapshotNodeType.Method:
                    string[] methodQualifers = node.Content.Split(';');
                    int      args            = 0;
                    string[] methargtypes    = methodQualifers[2].Split(',');
                    if (!string.IsNullOrEmpty(methodQualifers[2]))
                    {
                        args = methargtypes.Length;
                    }
                    if (methodQualifers.Length < 5)
                    {
                        CreateImportNodeIfRequired(methodQualifers[0]);

                        //gc.CreateImportNode(importNodesMapping[methodQualifers[0]], methodQualifers[0]);
                        gc.CreateMethodNode(node.Id, methodQualifers[1], args, methodQualifers[3], true);
                    }
                    else
                    {
                        CreateImportNodeIfRequired(methodQualifers[0]);

                        gc.CreateMethodNode(node.Id, methodQualifers[1], args, methodQualifers[3], methodQualifers[4], true);
                    }
                    break;

                case SnapshotNodeType.Property: string[] propertyQualifers = node.Content.Split(';');
                    CreateImportNodeIfRequired(propertyQualifers[0]);

                    //gc.CreateImportNode(importNodesMapping[propertyQualifers[0]], propertyQualifers[0]);
                    gc.CreatePropertyNode(node.Id, propertyQualifers[1], propertyQualifers[2]); break;

                case SnapshotNodeType.CodeBlock:
                {
                    string caption = node.Content;
                    if (GraphUtilities.AnalyzeString(caption) == SnapshotNodeType.Literal)
                    {
                        object parameter  = null;
                        int    intResult  = 0;
                        bool   boolResult = false;
                        double dblResult  = 0;
                        if (Int32.TryParse(caption, out intResult))
                        {
                            parameter = intResult;
                        }
                        else if (Double.TryParse(caption, out dblResult))
                        {
                            parameter = dblResult;
                        }
                        else if (Boolean.TryParse(caption, out boolResult))
                        {
                            parameter = boolResult;
                        }
                        else
                        {
                            parameter = caption;
                        }
                        gc.CreateLiteralNode(node.Id, parameter);
                    }
                    else
                    {
                        // Aparajit: Temporarily importing all the imported libraries by default to be able to
                        // call these functions from within a CodeBlock node

                        GraphUtilities.ForEachImportNodes((string hash, string path) => CreateImportNodeIfRequired(path, hash));

                        gc.CreateCodeblockNode(node);
                    }
                } break;

                case SnapshotNodeType.Array: gc.CreateArrayNode(node.Id, node.Content); break;
                }
            }
        }