Changeset 30885 in project


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

lexgen: ensure that that bind* calls the binding procedure even on empty input

File:
1 edited

Legend:

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

    r30860 r30885  
    2424
    2525  ( seq star bar
    26     try pass pos opt lst
     26    try pass pos opt lst eos
    2727    bind bind* rebind rebind* drop
    2828
    2929    lex
    30 
    3130    (Input->Token tok) <Token>
    3231    (Token->CharLex char range set lit) <CharLex>
     
    102101(define (star p)
    103102  (lambda (sk fk strm)
    104     (p (lambda (strm1)
    105         (if (eoi? (cadr strm1)) (sk strm1)
     103        (p (lambda (strm1)
     104            (if (eoi? (cadr strm1)) (sk strm1)
    106105             ((star p) sk sk strm1))) sk strm)))
    107106
    108107;; this parser always succeeds
     108
    109109(define (pass sk fk s) (sk s))
     110
     111;; this parser matches end of input
     112
     113(define (eos sk fk s) (if (eoi? (cadr s)) (sk s) (fk s)))
    110114 
    111115;; Positive closure. Analogous to '+'
     
    182186    (lambda (sk fk s)
    183187      (if (eoi? (cadr s))
    184           (sk s)
     188          (sk (ba (box-stream s)))
    185189          (let ((sk1 (lambda (s1) (sk (ba s1))))
    186190                (fk1 (lambda (s1) (fk s))))
     
    246250
    247251(define-record-type eoi (make-eoi) eoi?)
    248 
    249 
    250 ;; The following procedures are specific to the input class type
     252(define (stream-eoi? strm) (eoi? (cadr strm)))
    251253
    252254(define-class <Token> (<Input> input)  tok)
Note: See TracChangeset for help on using the changeset viewer.