guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: major change to argument processing.


From: Marius Vollmer
Subject: Re: RFC: major change to argument processing.
Date: 02 Jun 2001 03:20:13 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Rob Browning <address@hidden> writes:

> Marius Vollmer <address@hidden> writes:
> 
> > I think so, yes.  The effort is not really that large (I think Rob has
> > already written it).
> 
> Yes.

Here is some code for the parser I have in mind, to make things
clearer.

    (define (read-quoted-argument)
      ;; gobble whittespace
      (let loop ((ch (read-char)))
        (cond ((eof-object? ch)
               ch)
              ((char-whitespace? ch)
               (loop (read-char)))
              (else
               ;; gather argument chars
               (let loop ((arg '())
                          (ch ch)
                          (state 'free))
                 (cond ((or (eof-object? ch)
                            (and (eq? state 'free) (char-whitespace? ch)))
                        (list->string (reverse! arg)))
                       ((and (not (eq? state 'single)) (eq? ch #\\))
                        (let ((ch (read-char)))
                          (if (eof-object? ch)
                              (error "escape at end of file"))
                          (loop (cons ch arg) (read-char) state)))
                       ((and (not (eq? state 'double)) (eq? ch #\'))
                        (loop arg (read-char)
                              (if (eq? state 'single) 'free 'single)))
                       ((and (not (eq? state 'single)) (eq? ch #\"))
                        (loop arg (read-char)
                              (if (eq? state 'double) 'free 'double)))
                       (else
                        (loop (cons ch arg) (read-char) state))))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]