Parsing PGN files - when can a move be shortened? I'm writing a PGN file parser, and need to know in which situations you don't need to write the rank/file of a piece that makes the move. I can think of the following:


only one piece can conduct the move according to the rules of movement (i.e. attempting to move a bishop horizontally - that's obvious).
both pieces can move to the given square, but all but one are obstructed by other pieces
all but one of the pieces are pinned and moving them would expose the king to check


Anything else I'm missing? 

I'd also like to add some seemingly ambiguous situations:



Black to move. Is Nc5+ valid PGN, or would it be Nbc5+? Is Nc5 valid, or would it be Nec5?



Black to move. Is Rg7# / Rg7+ valid PGN, or do I need to specify the rank here?

What if two pieces can move to the same square, but one of the moves would result in threefold repetition, and the game doesn't stop instantly?

What if two pieces can move to the same square, one of those moves forces a mate-in-one on the moving side, and the move is labeled "!!"? :)
From the PGN specification (http://www6.chessclub.com/help/PGN-spec):


  Neither the appearance nor the absence of either a check or
  checkmating indicator is used for disambiguation purposes.  This means
  that if two (or more) pieces of the same type can move to the same
  square the differences in checking status of the moves does not
  allieviate the need for the standard rank and file disabiguation
  described above.  (Note that a difference in checking status for the
  above may occur only in the case of a discovered check.)


This means you have to specify files respectively ranks in your two diagram examples.

My understanding is that you need to disambiguate in the last two situations you describe as well.