What is the correct grammar to parse a move in SAN format using PEG?
The solution I come up is
MOVE <- [NBRQK]? [a-h]? [1-8]? [-x]? [a-h] [1-8] [NBRQ]?
However, this seems wrong as it doesn't parse Nh4 because h matches the first optional file [a-h]? and the parser doesn't backtrack.
Other moves that should be correctly parsed are: a4, a3a4, xa4, a8Q, xa8Q, Nh4, Nxh4, Ngxh4, Ng3h4,Ngh4, N3h4, Ng3-h4, Ng3xh4, but (optionally) not -a4, N-h4.