Changeset 30860 in project


Ignore:
Timestamp:
05/14/14 02:51:14 (6 years ago)
Author:
Ivan Raikov
Message:

lexgen: added bind* and rebind* variants of bind and rebind

Location:
release/4/lexgen/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/lexgen/trunk/lexgen.scm

    r27877 r30860  
    44;;  Based on the SML lexer generator by Thant Tessman.
    55;;
    6 ;;  Copyright 2009-2012 Ivan Raikov and the Okinawa Institute of
     6;;  Copyright 2009-2014 Ivan Raikov and the Okinawa Institute of
    77;;  Science and Technology.
    88;;
     
    2525  ( seq star bar
    2626    try pass pos opt lst
    27     bind drop rebind
     27    bind bind* rebind rebind* drop
    2828
    2929    lex
     
    167167
    168168;; Binds a procedure f to the consumed tokens returned by p
     169;; Calls failure on empty input
    169170(define (bind f p)
    170171  (let ((ba (bind-apply f)))
    171172    (lambda (sk fk s)
    172       (if (eoi? (cadr s)) (fk s)
     173      (if (eoi? (cadr s))
     174          (fk s)
     175          (let ((sk1 (lambda (s1) (sk (ba s1))))
     176                (fk1 (lambda (s1) (fk s))))
     177            (p sk1 fk1 (box-stream s)))))))
     178
     179;; Same as bind, but calls success on empty input
     180(define (bind* f p)
     181  (let ((ba (bind-apply f)))
     182    (lambda (sk fk s)
     183      (if (eoi? (cadr s))
     184          (sk s)
    173185          (let ((sk1 (lambda (s1) (sk (ba s1))))
    174186                (fk1 (lambda (s1) (fk s))))
     
    198210;; Applies a procedure f to the un-consumed tokens, then applies
    199211;; procedure g to the result of f and the tokens returned by p
     212;; Calls failure on empty input
    200213(define (rebind f g p)
    201214  (let ((ra (rebind-apply g)))
    202215    (lambda (sk fk s)
    203       (if (eoi? (cadr s)) (fk s)
     216      (if (eoi? (cadr s))
     217          (fk s)
     218          (let* ((info   ((compose f cadr) s))
     219                 (sk1    (lambda (s) (sk (ra info s)))))
     220            (p sk1 fk (box-stream s)))))))
     221
     222;; Same as rebind, but calls success on empty input
     223(define (rebind* f g p)
     224  (let ((ra (rebind-apply g)))
     225    (lambda (sk fk s)
     226      (if (eoi? (cadr s))
     227          (sk s)
    204228          (let* ((info   ((compose f cadr) s))
    205229                 (sk1    (lambda (s) (sk (ra info s)))))
  • release/4/lexgen/trunk/lexgen.setup

    r27877 r30860  
    1616 
    1717  ;; Assoc list with properties for your extension:
    18   '((version 6.2)
     18  '((version 7.0)
    1919    ))
Note: See TracChangeset for help on using the changeset viewer.