let rec pop tokens s lexbuf =
  match !blocks with
    [] ->
      prerr_blocks_stack ();
      raise (Error (End_with_no_begin s, curr_loc lexbuf))
  | (tok, vext, vin) :: q ->
      blocks := q;
      last_popped := Some (tok,vext,vin);
      if List.mem tok tokens then
        (
         prerr_endline (Printf.sprintf "popped %s (%d;%d)" (string_of_token tok) vext vin);
         (vext, vin)
        )
      else
        match tok with
          MATCH | TRY | FUN | FUNCTION | FUNCTOR | MINUSGREATER | MODULE
        | WITH | METHOD | VAL | ELSE | THEN | INCLUDE | LET
        | EXCEPTION | TYPE | INITIALIZER ->
             (* we can pop these ones and try with the next token
                because these contructions don't have an explicit end; *)

            pop tokens s lexbuf
        | _ ->
             (* we could jump the bad token to try to indent anyway
                but the result would be wrong *)

            prerr_blocks_stack ();
            raise (Error (End_with_no_begin s, curr_loc lexbuf))