anchor.diff:  let createParserForwardedToRef<'a, 'r when 'r : equality>(name:string) = 
       let r = ref dummyParser<'a, 'r>
       { new NonTerminalParser<'a, 'r>() with 
  -      override this.Chain(t, inp) (f) = (!r).Chain(t, inp) (f) } :> Parser<'a, 'r>, r
  -
  -let runParser (p: Parser<'a, 'r>) (s: 'a seq) : ParserResult<'r> list = 
  +      override this.Chain s f = (!r).Chain s f } :> Parser<'a, 'r>, r
  +
  +let runParser (p: Parser<'a, 'r>) (s: 'a seq) : ParserResult<'a, 'r> list = 
       let res = p.Apply(new ArrayInputStream<'a>(Seq.toArray s, 0))
       if res.IsEmpty then failwith msgLibraryError
       res |> List.map parserResult<'a, 'r>
  
positive.code: //    p >>= fun (x: 'r1) -> q >>% x
  let (.>>)<'a, 'r, 'r2 when 'r: equality and 'r2 : equality> (p: Parser<'a, 'r>) (q: Parser<'a, 'r2>) : Parser<'a, 'r> = 
      { new NonTerminalParser<'a, 'r>() with 
        override nt.Chain(t, inp) (f) = 
              t.Add(p, inp) (Cont.New(fun (t, r) ->
                   match r with 
                   | :? GSuccess<'a, 'r> as s1 -> 
                       q.Chain(t, s1.Tail) (Cont.WithSucc (fun s -> success<'a, 'r> s1.Value s.Tail) f)
                   | fail -> (t, fail) |> f.F))
      } :> Parser<'a, 'r>
  
  //let (>>.) this that = this >>= fun _ -> that
  let (>>.)<'a, 'r, 'r2 when 'r: equality and 'r2 : equality> (p: Parser<'a, 'r>) (q: Parser<'a, 'r2>) : Parser<'a, 'r2> = 
      { new NonTerminalParser<'a, 'r2>() with 
        override nt.Chain (t, s) f = 
            t.Add(p, s) (Cont.New(fun (t, r) -> if r.Succeeded then q.Chain(t, r.Tail) (f) else (t, r) |> f.F))
      } :> Parser<'a, 'r2>
  
  let (.>>.) p1 p2 = 
  
negative.code:     Successes: SSet<'a>
      Failures: SSet<'a>
      Postrace: string list
      DisRes: Map<int, SSet<'a> >
  } 
  and T () =
       
      static member AddResult<'a> (r: GParserResult<'a>) : PState<'a> = 
          getState >>= fun t ->
              putState <| if r.Succeeded then { t with Successes = t.Successes.Add(r) }
                                         else { t with Failures = t.Failures.Add(r) }
  
      static member Run<'a> () : PState<'a> = state { 
          let! t = getState
          if not (List.isEmpty t.Queue || t.Stopped) then
              do! T.Step ()
              return! T.Run ()
      }
           
      static member Stop<'a> () : PState<'a> = modify (fun t -> { t with Stopped = true })
  
      static member Step<'a> () : PState<'a> = state { 
          let! t1 = getState
          let p, s = t1.Queue.Head
          do! modify (fun t -> { t with Queue = List.tail t.Queue })
          do! p.Chain (s) (Cont.New(fun res -> state {
              let! t = getState
              let popped =
                  let parsers = match t.Popped.TryFind(s) with | Some ps -> ps | _ -> Map.empty
                  let rset = match parsers.TryFind(p) with | Some rs -> rs 
                                                           | _ -> (if res.Succeeded then Set.singleton res else Set.empty)
                  t.Popped.Add(s, parsers.Add(p, rset))
  
              do! modify (fun t -> { t with Popped = popped })
              let! t = getState
              let links = t.Backlinks.[s].[p] |> Seq.toList
              // TODO OK  ???
              match t.Saved.TryFind(res) with
              | Some _ ->
                  for f in links do
                      let! t = getState
                      let set = t.Saved.[res]              // TODO CAN BE A BUG
                      if not (set.Contains(f)) then
                          do! modify (fun t -> { t with Saved = t.Saved.Add(res, set.Add f) })
                          do! res |> f.F
              | _ -> 
                  do! modify (fun t -> { t with Saved = t.Saved.Add (res, Set.empty) } )
                  for f in links do
                      let! t = getState
                      let set = t.Saved.[res]
                      do! modify (fun t -> { t with Saved = t.Saved.Add(res, set.Add f) }) 
                      do! res |> f.F
              }
          ))
          }
  
      static member Add<'a> (p: GParser<'a>, s: InputStream<'a>) (f: Continuation<'a>) : PState<'a> = state {
          let tuple = (p, s)
          let! t = getState
          let backlinks = 
              let parsers = match t.Backlinks.TryFind(s) with | Some ps -> ps | _ -> Map.empty
              let fset = match parsers.TryFind(p) with | Some fs -> fs | _ -> Set.singleton f
              t.Backlinks.Add(s, parsers.Add(p, fset))
          do! modify <| fun t -> { t with Backlinks = backlinks }
          let! t = getState
          match t.Popped.TryFind(s) with
          | Some parsers when parsers.ContainsKey p ->
              for res in parsers.[p] do
                  do! f.F (res) // if we've already done that, use the result
          | _ ->
              let parsers = match t.Done.TryFind(s) with | Some ps -> ps | _ -> Set.empty
              if not (parsers.Contains p) then 
                  do! modify (fun t -> { t with Queue = tuple :: t.Queue; Done = t.Done.Add(s, parsers.Add p) })
          }
  
  #nowarn "1189"
  
  let inline preturn<'a, 'r when 'r: equality> (a: 'r) : Parser<'a, 'r> = 
      { new TerminalParser<'a, 'r>() 
        with override this.Parse inp = success<'a, 'r> a inp } :> Parser<'a, 'r>
  
  let inline perror<'a, 'r when 'r: equality> (msg: string) : Parser<'a, 'r> = 
      { new TerminalParser<'a, 'r>() 
        with override this.Parse inp = failure<'a> msg inp } :> Parser<'a, 'r>
  
  let inline satisfy<'a when 'a: equality> (pred : 'a -> bool) = 
      { new TerminalParser<'a, 'a>() with 
        override this.Parse (s: InputStream<'a>) =
          if s.IsEmpty then failure<'a> "UnexpectedEOF" s
  