Good question. This nested notation (also called: recursive annotation variation, RAV for short) is uncommon but valid[*]. In the example you provide, most online PGN readers have no problem parsing and accounting for all the variations and subvariations. So the way to read it is as follows: the nested structure is composed of independent variations, only if there's a closing parenthesis then it is an actual subvariation (so a specific branch out of a previous variation). An example from your PGN: 8... Qc7
is a variation, (9.Qe1...)
is a subvariation and (10.Bf3...)
is a subsubvariation. So the nesting is: (8... Qc7 (subvariation (subsubvar...) ))
.
Various libraries/modules may not have a built-in parsing system to tackle such PGN structure[**], so you may have to extend this on your own. For further reading, Tim Harding also explains the nested notation and its lack of implementation rather more succinctly here, I briefly quote:
An RAV (Recursive Annotation Variation) is a sequence of movetext
containing one or more moves enclosed in parentheses. An RAV is used
to represent an alternative variation. The alternate move sequence
given by an RAV is one that may be legally played by first unplaying
the move that appears immediately prior to the RAV. Because the RAV is
a recursive construct, it may be nested. ...
Some software may find it
hard to handle nested variations too. Palview3 was the first
freely-available PGN software, that I am aware of, that could create
with variations in HTML pages, and it is restricted to two levels of
notes (three levels counting the actual moves of the game). For most
purposes, this is sufficient. Most Java Viewers can only show the
actually played moves, except as text notes, but playing through a
Palview3 web page is close to the experience of playing it through in
a program like ChessBase: a major advance for chess webmasters.
That said, nowadays, there are various online pgn-readers that already do this, some examples (so if you paste your PGN onto either of these, it can be fully read and displayed).
You may find additional information on the standards of PGN here. I will get back to you if I find other potentially useful elements.
[*]: just to make sure, I also quickly parsed the text to make sure all parentheses are properly closed.
[**]: for example, the chess.pgn.read_game
method from python-chess
fails to fully read this PGN, it only sees the main variation upto move 8... e5.