anchor.diff:      let dummyFam = Family()
       let currentN = ref <| dummyAST
       let currentR = ref <| dummyAST
  -    let gss = Array.init length (fun _ -> new ResizeArray<Vertex>())
  -    gss.[!currentIndex].Add dummyGSSNode
  +    // let edges = Array2D.init inputLength inputLength (fun _ _ -> new ResizeArray<Edge>())
  + 
  +    let gss = Array.init inputLength (fun _ -> new ResizeArray<Vertex>())
       let currentGSSNode = ref <| packVertex !currentIndex (gss.[!currentIndex].Count - 1)
       let dummyGSSNode = packVertex !currentIndex (gss.[!currentIndex].Count - 1)
       let currentContext = ref <| new Context(!currentIndex, !currentLabel, !currentGSSNode, dummyAST)
       let createdFamilies = Array.init parser.rulesCount (fun _ -> new Dictionary<int64<key>, ResizeArray<Family>>())  
   
       let terminalNodes = new BlockResizeArray<ExtensionTree>()
  -    let finalExtension = pack3ToInt64 parser.StartRule 0 inputLength
  -    member this.inputLength = length
  -
  -let drawDot (parser : ParserSource2<'TokenType>) (tokens : 'TokenType[])(path : string) (gss : array<ResizeArray<Vertex>>) =
  -    use out = new System.IO.StreamWriter (path)
  -    let was = new Dictionary<_,_>()
  -    let levels = new Dictionary<_,_>()
  -    out.WriteLine "digraph GSS {"
  -    let print s = out.WriteLine ("    " + s)
  -    let curNum = ref 0
  -    print "rankdir=RL"
  -    let getAstString (ast : ExtensionTree) =
  -        let ast = ast.tree
  -        match ast with
  -       // | :? int as i when i >= 0 -> tokens.[i] |> parser.TokenToNumber |> parser.NumToString |> sprintf "%s"    
  -       // | :? int as i when i < 0 -> "eps " + parser.NumToString (-i - 1)
  -        | :? AST as ast -> 
  -            let nonT = 
  -                if ast.first.prod < parser.LeftSide.Length then ast.first.prod
  -                else -1
  -            nonT.ToString()
  -        | :? IntermidiateNode as iN ->
  -            (getRule iN.Position).ToString()
  -        | null -> "null" 
  -        | _ -> failwith "Unexpected ast"
  -
  -    let rec dfs (u : Vertex) =
  -        was.Add (u, !curNum)
  -        if not <| levels.ContainsKey u.Level then levels.[u.Level] <- [!curNum]
  +    let finalExtension = pack3ToInt64 parser.StartRule 0 inputLength
  +
  +    let condition = ref false 
  +    let stop = ref false
  +
  +    let drawDot (parser : ParserSource2<'TokenType>) (tokens : 'TokenType[])(path : string) (gss : array<ResizeArray<Vertex>>) =
  +        use out = new System.IO.StreamWriter (path)
  +        let was = new Dictionary<_,_>()
  +        let levels = new Dictionary<_,_>()
  +        out.WriteLine "digraph GSS {"
  +        let print s = out.WriteLine ("    " + s)
  +        let curNum = ref 0
  +        print "rankdir=RL"
  +        let getAstString (ast : ExtensionTree) =
  +            let ast = ast.tree
  +            match ast with
  +            // | :? int as i when i >= 0 -> tokens.[i] |> parser.TokenToNumber |> parser.NumToString |> sprintf "%s"    
  +            // | :? int as i when i < 0 -> "eps " + parser.NumToString (-i - 1)
  +            | :? AST as ast -> 
  +                let nonT = 
  +                    if ast.first.prod < parser.LeftSide.Length then ast.first.prod
  +                    else -1
  +                nonT.ToString()
  +            | :? IntermidiateNode as iN ->
  +                (getRule iN.Position).ToString()
  +            | null -> "null" 
  +            | _ -> failwith "Unexpected ast"
  +
  +        let rec dfs (u : Vertex) =
  +            was.Add (u, !curNum)
  +            if not <| levels.ContainsKey u.Level then levels.[u.Level] <- [!curNum]
  +            else
  +                levels.[u.Level] <- !curNum :: levels.[u.Level]
  +            if (getRule u.Label = -1) then print <| sprintf "%d [label=\"%s\"]" !curNum "dummy node"
  +            else print <| sprintf "%d [label=\"(%d, %d), %d\"]" !curNum (getRule u.Label) (getPosition u.Label) u.Level
  +            incr curNum
  +            if u.OutEdges.first <> Unchecked.defaultof<_> 
  +            then 
  +                handleEdge u u.OutEdges.first
  +                if u.OutEdges.other <> null then u.OutEdges.other |> Array.iter (handleEdge u)
  +
  +        and handleEdge u (e : Edge) =
  +            let v = gss.[getIndex2Vertex e.Dest].[getIndex1Vertex e.Dest]
  +            if not <| was.ContainsKey v then dfs v
  +            print <| sprintf "%d -> %d [label=\"%s\"]" was.[u] was.[v] (getAstString e.Ast)
  +        for levels in gss do
  +            for v in levels do
  +                if not <| was.ContainsKey v then dfs v
  +    
  +        for level in levels do
  +            print <| sprintf "{rank=same; %s}" (level.Value |> List.map (fun (u : int) -> string u) |> String.concat " ")
  +
  +        out.WriteLine "}"
  +        out.Close()
  +
  +
  +    let findFamily prod (nodes : INode) extension : Family =
  +        let mutable result = None
  +        let res = ref <| null
  +        let exists = createdFamilies.[prod].TryGetValue(extension, res)
  +        if exists
  +        then 
  +            let fams = !res
  +            let contains = fams |> ResizeArray.tryFind (fun f -> f.node = nodes )
  +            if not contains.IsSome
  +            then
  +                let temp = new Family(prod, nodes)
  +                createdFamilies.[prod].[extension].Add temp
  +                temp
  +            else contains.Value
           else
  -            levels.[u.Level] <- !curNum :: levels.[u.Level]
  -        if (getRule u.Label = -1) then print <| sprintf "%d [label=\"%s\"]" !curNum "dummy node"
  -        else print <| sprintf "%d [label=\"(%d, %d), %d\"]" !curNum (getRule u.Label) (getPosition u.Label) u.Level
  -        incr curNum
  -        if u.OutEdges.first <> Unchecked.defaultof<_> 
  -        then 
  -            handleEdge u u.OutEdges.first
  -            if u.OutEdges.other <> null then u.OutEdges.other |> Array.iter (handleEdge u)
  -
  -    and handleEdge u (e : Edge) =
  -        let v = gss.[getIndex2Vertex e.Dest].[getIndex1Vertex e.Dest]
  -        if not <| was.ContainsKey v then dfs v
  -        print <| sprintf "%d -> %d [label=\"%s\"]" was.[u] was.[v] (getAstString e.Ast)
  -    for levels in gss do
  -        for v in levels do
  -            if not <| was.ContainsKey v then dfs v
  -    
  -    for level in levels do
  -        print <| sprintf "{rank=same; %s}" (level.Value |> List.map (fun (u : int) -> string u) |> String.concat " ")
  -
  -    out.WriteLine "}"
  -    out.Close()
  -
  -
  -let findFamily prod (nodes : INode) extension : Family =
  -    let mutable result = None
  -    let res = ref <| null
  -    let exists = createdFamilies.[prod].TryGetValue(extension, res)
  -    if exists
  -    then 
  -        let fams = !res
  -        let contains = fams |> ResizeArray.tryFind (fun f -> f.node = nodes )
  -        if not contains.IsSome
  -        then
               let temp = new Family(prod, nodes)
  -            createdFamilies.[prod].[extension].Add temp
  +            let v = new ResizeArray<Family>()
  +            v.Add temp
  +            createdFamilies.[prod].Add(extension, v)
               temp
  -        else contains.Value
  -    else
  -        let temp = new Family(prod, nodes)
  -        let v = new ResizeArray<Family>()
  -        v.Add temp
  -        createdFamilies.[prod].Add(extension, v)
  -        temp
  -
  -let handleIntermidiate (node : INode) prod extension =
  -    let family = findFamily prod node extension
  -    family
  -
  -let containsContext index label  (gssNode : int64<vertex>) (ast : INode) =
  -    let set = setU.[index]
  -    let key = (label, gssNode)
  -    let res = ref null
  -    let contains = set.TryGetValue(key, res)
  -    if contains
  -    then
  -        let t = ResizeArray.exists (fun e -> e = null && ast = null || (ast <> null && e <> null && e = ast)) !res
  -        contains, t , key
  +
  +    let handleIntermidiate (node : INode) prod extension =
  +        let family = findFamily prod node extension
  +        family
  +
  +    let containsContext index label  (gssNode : int64<vertex>) (ast : INode) =
  +        let set = setU.[index]
  +        let key = (label, gssNode)
  +        let res = ref null
  +        let contains = set.TryGetValue(key, res)
  +        if contains
  +        then
  +            let t = ResizeArray.exists (fun e -> e = null && ast = null || (ast <> null && e <> null && e = ast)) !res
  +            contains, t , key
                   
  -    else false, false, key
  -
  - let addContext label (index : int) (node : int64<vertex>) (ast : ExtensionTree) =
  +        else false, false, key
  +
  +    let addContext label (index : int) (node : int64<vertex>) (ast : ExtensionTree) =
               let containsKey, containsTree, key = containsContext index label node ast.tree
               if index <= inputLength + 1 && index >= 0 && not containsTree
               then
  
positive.code:     | Success of Tree<'TokenType>
      | Error of string
  
  type SourceFile<'TokenType>(tokens : seq<'TokenType>, parser : ParserSource2<'TokenType>) =
      let tokens = Seq.toArray tokens
      let length = Seq.length tokens
      let resultAST = ref None
      let setR = new Queue<Context>()   
      let setP = new System.Collections.Generic.Dictionary<int64<vertex>,ResizeArray<ExtensionTree>> ()
      let astDictionary = new System.Collections.Generic.Dictionary<int64<key>,AST> ()
      let setU = Array.init (length + 1) (fun _ -> new Dictionary<_*_, ResizeArray<INode>>())
              
      let currentIndex = ref 0
  
  
negative.code:                 currentN := currentContext.Value.Ast 
                  currentR := dummyAST
                  functions.[!currentLabel] !currentIndex !currentGSSNode !currentR !currentN
  
      member this.Pop = pop
      member this.AddContext = addContext
      member this.Create = create
      member this.Test = test
      member this.GetNodeT = getNodeT
      member this.GetNodeP = getNodeP   
     
  //                      
  //        match !resultAST with
  //            | None -> Error ("String was not parsed")
  //            | Some res -> 
  //                    drawDot parser tokens "gss.dot" gss
  //                    let r1 = new Tree<_> (tokens, res, parser.rules)
  //                    Success (r1)       
  