[LIB-9] Add reserved, NAG and semicolon comment PGN tokens
[chesshog.git] / chesshog-format / src / main / java / org / hedgecode / chess / pgn / token / MoveToken.java
index ea89dfc..0191ad4 100644 (file)
@@ -23,7 +23,6 @@ import org.hedgecode.chess.ParseException;
 import org.hedgecode.chess.pgn.entity.DetailMove;
 import org.hedgecode.chess.pgn.entity.MoveNumber;
 import org.hedgecode.chess.pgn.entity.Moves;
-import org.hedgecode.chess.pgn.nag.Glyph;
 import org.hedgecode.chess.pgn.token.san.CommonSANToken;
 import org.hedgecode.chess.pgn.token.san.SANToken;
 
@@ -34,7 +33,7 @@ import org.hedgecode.chess.pgn.token.san.SANToken;
  */
 public class MoveToken implements Token<Moves> {
 
-    public static final String MOVE_REGEX = "^\\s*([PNBRQKa-hx1-8=+#\\-O!?]+)(\\s+\\$([0-9]+))?";
+    public static final String MOVE_REGEX = "^\\s*([PNBRQKa-hx1-8=+#\\-O!?]+)";
     private static final Pattern MOVE_PATTERN = Pattern.compile(MOVE_REGEX);
     private static final int MOVE_GROUP = 1, NAG_GROUP = 3;
 
@@ -46,9 +45,9 @@ public class MoveToken implements Token<Moves> {
         MoveNumber moveNumber = new MoveNumber(
                 moves.currentMove().ply()
         );
-        int numberLength = moveNumberToken.token(moveNumber, pgn);
-        if (numberLength > 0) {
-            pgn = pgn.substring(numberLength);
+        int numLength = moveNumberToken.token(moveNumber, pgn);
+        if (numLength > 0) {
+            pgn = pgn.substring(numLength);
         }
         Matcher matcher = MOVE_PATTERN.matcher(pgn);
         if (!matcher.find()) {
@@ -62,16 +61,8 @@ public class MoveToken implements Token<Moves> {
             moves.addMove(
                     detailMove
             );
-            String glyph = matcher.group(NAG_GROUP); // todo: more then one NAG
-            if (glyph != null) {
-                detailMove.addGlyph(
-                        Glyph.byNumber(
-                                Integer.parseInt(glyph)
-                        )
-                );
-            }
         }
-        return numberLength + matcher.group().length();
+        return numLength + matcher.group().length();
     }
 
 }