cheeplay

chess PGN replay in the terminal
git clone git://git.alexkarle.com.com/cheeplay
Log | Files | Refs | README | LICENSE

commit 8d78b3ae7e2fd121a192a48f821abe9dee8eeff7 (patch)
parent 982629b822f8419398ef17b56abf26a79f2acc14
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat, 14 May 2022 17:38:47 -0400

Read in PGN file, print tags before board

No other parsing happening... yet!

Diffstat:
Mcheeplay.scm | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/cheeplay.scm b/cheeplay.scm @@ -1,5 +1,5 @@ #!/usr/local/bin/chicken-csi -ss -(import (chicken format)) +(import (chicken io) (chicken format)) (define B '((BR BN BB BQ BK BB BN BR) @@ -39,8 +39,23 @@ (define (prboard) (fori B (lambda (row i) - (fori row (lambda (x j) (prpiece x i j))) - (newline)))) + (fori row (lambda (x j) (prpiece x i j))) + (newline)))) + +(define (replay file) + (call-with-input-file file (lambda (p) + (define (parse section) + (let ((l (read-line p))) + (if (not (eof-object? l)) + (if (eq? section 'tag) + (begin (print l) + (if (equal? l "") + (parse 'movetext) + (parse 'tag))) + (prboard))))) + (parse 'tag)))) (define (main args) - (prboard)) + (if (null? args) + (display "usage: cheeplay FILE.pgn\n") + (replay (car args))))