[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-58-g65fa60
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-58-g65fa60c |
Date: |
Thu, 03 Mar 2011 22:54:49 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=65fa60ca7a7bbfd712371f7b2471efe7b056839c
The branch, stable-2.0 has been updated
via 65fa60ca7a7bbfd712371f7b2471efe7b056839c (commit)
via 859e58ae8a77c0c725a5027d1bb3809e9772076e (commit)
from d900843c72ee1f34d79527deb38787e581592cf5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 65fa60ca7a7bbfd712371f7b2471efe7b056839c
Author: Andy Wingo <address@hidden>
Date: Thu Mar 3 23:51:20 2011 +0100
repl.scm understands comments
* module/system/repl/repl.scm (read-comment, read-scheme-line-comment)
(read-scheme-datum-comment): New helpers.
(meta-reader): Take a language instead of a reader. If we have a
nonwhitespace char, first check to see that it's a comment, and if so,
read it off and loop.
(prompting-meta-read): Call meta-reader with the lang.
commit 859e58ae8a77c0c725a5027d1bb3809e9772076e
Author: Andy Wingo <address@hidden>
Date: Thu Mar 3 23:19:35 2011 +0100
repl.scm refactor
* module/system/repl/repl.scm (flush-leading-whitespace): Rename from
next-char.
(meta-reader): Use flush-leading-whitespace.
(run-repl): Use flush-to-newline after the evaluation, which seems to
be the same as what we did before.
-----------------------------------------------------------------------
Summary of changes:
module/system/repl/repl.scm | 70 ++++++++++++++++++++++++++++++++++--------
1 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index 0d7aca7..39f2319 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -32,6 +32,48 @@
#:export (start-repl run-repl))
+;;;
+;;; Comments
+;;;
+;;; (You don't want a comment to force a continuation line.)
+;;;
+
+(define (read-scheme-line-comment port)
+ (let lp ()
+ (let ((ch (read-char port)))
+ (or (eof-object? ch)
+ (eqv? ch #\newline)
+ (lp)))))
+
+(define (read-scheme-datum-comment port)
+ (read port))
+
+;; ch is a peeked char
+(define (read-comment lang port ch)
+ (and (eq? (language-name lang) 'scheme)
+ (case ch
+ ((#\;)
+ (read-char port)
+ (read-scheme-line-comment port)
+ #t)
+ ((#\#)
+ (read-char port)
+ (case (peek-char port)
+ ((#\;)
+ (read-char port)
+ (read-scheme-datum-comment port)
+ #t)
+ ;; Not doing R6RS block comments because of the possibility
+ ;; of read-hash extensions. Lame excuse. Not doing scsh
+ ;; block comments either, because I don't feel like handling
+ ;; #!r6rs.
+ (else
+ (unread-char #\# port)
+ #f)))
+ (else
+ #f))))
+
+
;;;
;;; Meta commands
@@ -39,11 +81,11 @@
(define meta-command-token (cons 'meta 'command))
-(define (meta-reader read env)
+(define (meta-reader lang env)
(lambda* (#:optional (port (current-input-port)))
(with-input-from-port port
(lambda ()
- (let ((ch (next-char #t)))
+ (let ((ch (flush-leading-whitespace)))
(cond ((eof-object? ch)
;; EOF objects are not buffered. It's quite possible
;; to peek an EOF then read something else. It's
@@ -52,7 +94,9 @@
((eqv? ch #\,)
(read-char port)
meta-command-token)
- (else (read port env))))))))
+ ((read-comment lang port ch)
+ *unspecified*)
+ (else ((language-reader lang) port env))))))))
(define (flush-all-input)
(if (and (char-ready?)
@@ -70,8 +114,7 @@
(catch #t
(lambda ()
(repl-reader (lambda () (repl-prompt repl))
- (meta-reader (language-reader (repl-language repl))
- (current-module))))
+ (meta-reader (repl-language repl) (current-module))))
(lambda (key . args)
(case key
((quit)
@@ -116,7 +159,7 @@
(let prompt-loop ()
(let ((exp (prompting-meta-read repl)))
(cond
- ((eqv? exp *unspecified*)) ; read error, pass
+ ((eqv? exp *unspecified*)) ; read error or comment, pass
((eq? exp meta-command-token)
(catch #t
(lambda ()
@@ -157,18 +200,17 @@
(lambda (k . args)
(abort args))))
#:trap-handler 'disabled)))
- (next-char #f) ;; consume trailing whitespace
+ (flush-to-newline) ;; consume trailing whitespace
(prompt-loop))))
(lambda (k status)
status)))
-(define (next-char wait)
- (if (or wait (char-ready?))
- (let ((ch (peek-char)))
- (cond ((eof-object? ch) ch)
- ((char-whitespace? ch) (read-char) (next-char wait))
- (else ch)))
- #f))
+;; Returns first non-whitespace char.
+(define (flush-leading-whitespace)
+ (let ((ch (peek-char)))
+ (cond ((eof-object? ch) ch)
+ ((char-whitespace? ch) (read-char) (flush-leading-whitespace))
+ (else ch))))
(define (flush-to-newline)
(if (char-ready?)
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-58-g65fa60c,
Andy Wingo <=