diff options
| author | Mario Lang <mlang@delysid.org> | 2004-02-05 22:07:16 +0000 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2004-02-05 22:07:16 +0000 |
| commit | c5630a5b551392d7189c00b2060a018c3b876c7f (patch) | |
| tree | 6cd90e4488248d338285dd9bf32b8a6c2406d345 | |
| parent | 130c3e15e287192bf3dda8dc8c084bfdcf3c5fd6 (diff) | |
(chess-game-to-epd): New defsubst to convert a game
object to an EPD string (or insert it).
(chess-epd-to-game): Analogous to the above.
(chess-epd-parse): Use `chess-fen-regexp'.
| -rw-r--r-- | chess-epd.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/chess-epd.el b/chess-epd.el index 49f7b1f..b4b4232 100644 --- a/chess-epd.el +++ b/chess-epd.el @@ -89,10 +89,16 @@ and advance point after the correctly parsed position." (nconc positions (list pos)))) (cdr positions))) +(defsubst chess-game-to-epd (game &optional to-string index) + (if to-string + (chess-pos-to-epd (chess-game-pos game index)) + (insert (chess-pos-to-epd (chess-game-pos game index)) ?\n))) + +(defsubst chess-epd-to-game (&optional string) + (chess-game-create (chess-epd-to-pos string))) + (defun chess-epd-parse () - (when (re-search-forward - "\\([bnrqkpBNRQKP1-8]*/?\\)+ [bw] \\(-\\|[KQkq]+\\) \\(-\\|[1-8]\\)" - nil t) + (when (re-search-forward chess-fen-regexp nil t) (let ((pos (chess-fen-to-pos (match-string 0)))) (while (= 1 (skip-chars-forward " ")) (if (looking-at "[A-Za-z]") |
