Changeset 15069 in project


Ignore:
Timestamp:
06/26/09 04:41:28 (11 years ago)
Author:
Ivan Raikov
Message:

added variable-repetition to abnf

Location:
release/4/abnf
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/abnf/abnf.scm

    r14960 r15069  
    4141        (
    4242         (concatenation lex:seq) (alternatives lex:bar)
    43          repetition repetition1 repetition-n
     43         variable-repetition repetition repetition1 repetition-n
    4444         optional-sequence range set set-from-string
    4545
     
    160160(define range lex:range)
    161161
    162 ;; Repetition (RFC 4234, Section 3.6)
    163 (define (repetition p)  (lex:star p))
    164 
    165 ;; Convenience function for positive closure
    166 (define repetition1 lex:pos)
    167 
    168162;;  Specific repetition (RFC 4234, Section 3.7)
    169163(define (repetition-n n p)
     
    171165    (lex:lst ps)))
    172166
     167;; Variable repetition (RFC 4234, Section 3.6)
     168
     169;; * repetition
     170(define (repetition p)  (lex:star p))
     171
     172;; 1* repetition
     173(define repetition1 lex:pos)
     174
     175(define (variable-repetition min max p)
     176  (if (< max min) (variable-repetition max min p)
     177      (let loop ((i (- max 1)) (k (+ min 1)) (r (if (positive? min) (repetition-n min p) lex:pass)))
     178        (cond ((>= i min)  (loop (- i 1) (+ k 1) (lex:bar (repetition-n k p) r)))
     179              (else r)))))
     180
     181               
    173182(define optional-sequence lex:opt)
    174183
  • release/4/abnf/abnf.setup

    r14876 r15069  
    1717
    1818  ;; Assoc list with properties for your extension:
    19   '((version 2.0)
     19  '((version 2.1)
    2020    (documentation "abnf.html")
    2121    ))
Note: See TracChangeset for help on using the changeset viewer.