comparison lisp/emacs-lisp/rx.el @ 112122:a28fc1581b94

* lisp/emacs-lisp/rx.el (rx-repeat): Replace CL function.
author Glenn Morris <rgm@gnu.org>
date Tue, 04 Jan 2011 23:04:51 -0800
parents ad2a8fce0d7a
children
comparison
equal deleted inserted replaced
112121:a51d791afefe 112122:a28fc1581b94
1 ;;; rx.el --- sexp notation for regular expressions 1 ;;; rx.el --- sexp notation for regular expressions
2 2
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 5
6 ;; Author: Gerd Moellmann <gerd@gnu.org> 6 ;; Author: Gerd Moellmann <gerd@gnu.org>
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 ;; Keywords: strings, regexps, extensions 8 ;; Keywords: strings, regexps, extensions
9 9
410 (if (eq (1- char) (car m)) 410 (if (eq (1- char) (car m))
411 (setcar (memq m ranges) (1- char)) 411 (setcar (memq m ranges) (1- char))
412 (setcdr m (1- char))))) 412 (setcdr m (1- char)))))
413 ranges)) 413 ranges))
414 414
415 415
416 (defun rx-any-condense-range (args) 416 (defun rx-any-condense-range (args)
417 "Condense by side effect ARGS as range for Rx `any'." 417 "Condense by side effect ARGS as range for Rx `any'."
418 (let (str 418 (let (str
419 l) 419 l)
420 ;; set STR list of all strings 420 ;; set STR list of all strings
573 (unless (or (and (symbolp arg) 573 (unless (or (and (symbolp arg)
574 (string-match "\\`\\[\\[:[-a-z]+:\\]\\]\\'" 574 (string-match "\\`\\[\\[:[-a-z]+:\\]\\]\\'"
575 (condition-case nil 575 (condition-case nil
576 (rx-form arg) 576 (rx-form arg)
577 (error "")))) 577 (error ""))))
578 (eq arg 'word-boundary) 578 (eq arg 'word-boundary)
579 (and (consp arg) 579 (and (consp arg)
580 (memq (car arg) '(not any in syntax category)))) 580 (memq (car arg) '(not any in syntax category))))
581 (error "rx `not' syntax error: %s" arg)) 581 (error "rx `not' syntax error: %s" arg))
582 t) 582 t)
583 583
662 FORM is either `(repeat N FORM1)' or `(repeat N M FORMS...)'." 662 FORM is either `(repeat N FORM1)' or `(repeat N M FORMS...)'."
663 (rx-check form) 663 (rx-check form)
664 (if (> (length form) 4) 664 (if (> (length form) 4)
665 (setq form (rx-trans-forms form 2))) 665 (setq form (rx-trans-forms form 2)))
666 (if (null (nth 2 form)) 666 (if (null (nth 2 form))
667 (setq form (list* (nth 0 form) (nth 1 form) (nthcdr 3 form)))) 667 (setq form (cons (nth 0 form) (cons (nth 1 form) (nthcdr 3 form)))))
668 (cond ((= (length form) 3) 668 (cond ((= (length form) 3)
669 (unless (and (integerp (nth 1 form)) 669 (unless (and (integerp (nth 1 form))
670 (> (nth 1 form) 0)) 670 (> (nth 1 form) 0))
671 (error "rx `repeat' requires positive integer first arg")) 671 (error "rx `repeat' requires positive integer first arg"))
672 (format "%s\\{%d\\}" (rx-form (nth 2 form) '*) (nth 1 form))) 672 (format "%s\\{%d\\}" (rx-form (nth 2 form) '*) (nth 1 form)))
1159 ;; ;;;###autoload (autoload 'sregexq "rx" nil nil 'macro) 1159 ;; ;;;###autoload (autoload 'sregexq "rx" nil nil 'macro)
1160 ;; (defalias 'sregexq 'rx) 1160 ;; (defalias 'sregexq 'rx)
1161 1161
1162 (provide 'rx) 1162 (provide 'rx)
1163 1163
1164 ;; arch-tag: 12d01a63-0008-42bb-ab8c-1c7d63be370b
1165 ;;; rx.el ends here 1164 ;;; rx.el ends here