Changeset 11258 in project
- Timestamp:
- 07/11/08 04:40:23 (13 years ago)
- Location:
- chicken
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
chicken/branches/hygienic/regex.scm
r11149 r11258 174 174 ((newline-anycrlf) PCRE_NEWLINE_ANYCRLF) 175 175 ((bsr-anycrlf) PCRE_BSR_ANYCRLF) 176 ((bsr-unicode) PCRE_BSR_UNICODE) ) ) 177 176 ((bsr-unicode) PCRE_BSR_UNICODE) 177 (else 0) ) ) 178 179 (declare (hide pcre-options->number)) 180 181 (define (pcre-options->number opts) 182 (let loop ([opts opts] [opt 0]) 183 (if (null? opts) 184 opt 185 (loop (cdr opts) (+ opt (pcre-option->number (car opts)))) ) ) ) 178 186 179 187 ;;; The regexp structure primitives: … … 278 286 ;; Compile with subset of options and no tables 279 287 280 (define (regexp pattern . options) 281 (let ([options->integer 282 (lambda () 283 (if (null? options) 284 0 285 (+ (if (car options) PCRE_CASELESS 0) 286 (let ((options (cdr options))) 287 (if (null? options) 288 0 289 (+ (if (car options) PCRE_EXTENDED 0) 290 (let ((options (cdr options))) 291 (if (and (pair? options) (car options)) PCRE_UTF8 0 ) ) ) ) ) ) ) )]) 292 (%make-regexp (re-checked-compile pattern (options->integer) #f 'regexp)) ) ) 288 (define regexp 289 (let ([optspatt '(caseless extended utf8)]) 290 (lambda (pattern . options) 291 (let ([options->integer 292 (lambda () 293 (pcre-options->number (map (lambda (i o) (if i o 'zero)) options optspatt)))]) 294 (%make-regexp (re-checked-compile pattern (options->integer) #f 'regexp)) ) ) ) ) 293 295 294 296 ;; Compile with full options and tables available … … 299 301 (##sys#check-list options 'regexp*) 300 302 (when tables (##sys#check-chardef-table tables 'regexp*)) 301 (%make-regexp (re-checked-compile pattern (pcre-option ->number options) tables 'regexp*)) ) )303 (%make-regexp (re-checked-compile pattern (pcre-options->number options) tables 'regexp*)) ) ) 302 304 303 305 … … 668 670 "cannot select partial anchor for compiled regular expression") ) 669 671 (%regexp-options-set! rgxp 670 (bitwise-ior (%regexp-options regexp) 671 (pcre-option->number 'anchored))) 672 (+ (%regexp-options regexp) (pcre-option->number 'anchored))) 672 673 rgxp] ) ) ) ) ) -
chicken/trunk/regex.scm
r11041 r11258 653 653 (%regexp-options-set! rgxp 654 654 (bitwise-ior (%regexp-options regexp) 655 (pcre-option->number 'anchored)))655 (pcre-option->number 'anchored))) 656 656 rgxp] ) ) ) ) )
Note: See TracChangeset
for help on using the changeset viewer.