annotate lisp/emacs-lisp/rx.el @ 53370:3f0eafd05a7b

Document the change in insert-for-yank.
author Eli Zaretskii <eliz@is.elta.co.il>
date Mon, 29 Dec 2003 11:46:03 +0000
parents d5c1eeaa97e2
children 818e19ae4c5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; rx.el --- sexp notation for regular expressions
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Gerd Moellmann <gerd@gnu.org>
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Maintainer: FSF
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Keywords: strings, regexps, extensions
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; any later version.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; This is another implementation of sexp-form regular expressions.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; It was unfortunately written without being aware of the Sregex
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; package coming with Emacs, but as things stand, Rx completely
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; covers all regexp features, which Sregex doesn't, doesn't suffer
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; from the bugs mentioned in the commentary section of Sregex, and
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; uses a nicer syntax (IMHO, of course :-).
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; Rx translates a sexp notation for regular expressions into the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; usual string notation. The translation can be done at compile-time
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; by using the `rx' macro. It can be done at run-time by calling
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; function `rx-to-string'. See the documentation of `rx' for a
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; complete description of the sexp notation.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; Some examples of string regexps and their sexp counterparts:
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; "^[a-z]*"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; (rx (and line-start (0+ (in "a-z"))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; "\n[^ \t]"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; (rx (and "\n" (not blank))), or
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; (rx (and "\n" (not (any " \t"))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; "\\*\\*\\* EOOH \\*\\*\\*\n"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; (rx "*** EOOH ***\n")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; "\\<\\(catch\\|finally\\)\\>[^_]"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; (rx (and word-start (submatch (or "catch" "finally")) word-end
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; (not (any ?_))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; "[ \t\n]*:\\([^:]+\\|$\\)"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; (rx (and (zero-or-more (in " \t\n")) ":"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; (submatch (or line-end (one-or-more (not (any ?:)))))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;; (rx (and line-start
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; "content-transfer-encoding:"
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
64 ;; (+ (? ?\n)) blank
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; "quoted-printable"
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
66 ;; (+ (? ?\n)) blank))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; (concat "^\\(?:" something-else "\\)")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; (rx (and line-start (eval something-else))), statically or
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; (rx-to-string '(and line-start ,something-else)), dynamically.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;; (regexp-opt '(STRING1 STRING2 ...))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; (rx (or STRING1 STRING2 ...)), or in other words, `or' automatically
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; calls `regexp-opt' as needed.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; "^;;\\s-*\n\\|^\n"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; (rx (or (and line-start ";;" (0+ space) ?\n)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;; (and line-start ?\n)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; "\\$[I]d: [^ ]+ \\([^ ]+\\) "
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
81 ;; (rx (and "$Id: "
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
82 ;; (1+ (not (in " ")))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; " "
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; (submatch (1+ (not (in " "))))
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
85 ;; " "))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; "\\\\\\\\\\[\\w+"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; (rx (and ?\\ ?\\ ?\[ (1+ word)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;;
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; etc.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;;; History:
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
93 ;;
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;;; Code:
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (defconst rx-constituents
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 '((and . (rx-and 1 nil))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (or . (rx-or 1 nil))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (not-newline . ".")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (anything . ".\\|\n")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (any . (rx-any 1 1 rx-check-any))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (in . any)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (not . (rx-not 1 1 rx-check-not))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (repeat . (rx-repeat 2 3))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (submatch . (rx-submatch 1 nil))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (group . submatch)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (zero-or-more . (rx-kleene 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (one-or-more . (rx-kleene 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (zero-or-one . (rx-kleene 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (\? . zero-or-one)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (\?? . zero-or-one)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (* . zero-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (*? . zero-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (0+ . zero-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (+ . one-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (+? . one-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (1+ . one-or-more)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 (optional . zero-or-one)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (minimal-match . (rx-greedy 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (maximal-match . (rx-greedy 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (line-start . "^")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (line-end . "$")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (string-start . "\\`")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (string-end . "\\'")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (buffer-start . "\\`")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (buffer-end . "\\'")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (point . "\\=")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (word-start . "\\<")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (word-end . "\\>")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (word-boundary . "\\b")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (syntax . (rx-syntax 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (category . (rx-category 1 1 rx-check-category))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (eval . (rx-eval 1 1))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (regexp . (rx-regexp 1 1 stringp))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (digit . "[[:digit:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (control . "[[:cntrl:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (hex-digit . "[[:xdigit:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (blank . "[[:blank:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (graphic . "[[:graph:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (printing . "[[:print:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (alphanumeric . "[[:alnum:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (letter . "[[:alpha:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (ascii . "[[:ascii:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (nonascii . "[[:nonascii:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (lower . "[[:lower:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (punctuation . "[[:punct:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (space . "[[:space:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (upper . "[[:upper:]]")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (word . "[[:word:]]"))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 "Alist of sexp form regexp constituents.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 Each element of the alist has the form (SYMBOL . DEFN).
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 SYMBOL is a valid constituent of sexp regular expressions.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 If DEFN is a string, SYMBOL is translated into DEFN.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 If DEFN is a symbol, use the definition of DEFN, recursively.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 Otherwise, DEFN must be a list (FUNCTION MIN-ARGS MAX-ARGS PREDICATE).
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 FUNCTION is used to produce code for SYMBOL. MIN-ARGS and MAX-ARGS
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 are the minimum and maximum number of arguments the function-form
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 sexp constituent SYMBOL may have in sexp regular expressions.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 MAX-ARGS nil means no limit. PREDICATE, if specified, means that
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 all arguments must satisfy PREDICATE.")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (defconst rx-syntax
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 '((whitespace . ?-)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (punctuation . ?.)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (word . ?w)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (symbol . ?_)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 (open-parenthesis . ?\()
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (close-parenthesis . ?\))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (expression-prefix . ?\')
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (string-quote . ?\")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (paired-delimiter . ?$)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (escape . ?\\)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (character-quote . ?/)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 (comment-start . ?<)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (comment-end . ?>))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 "Alist mapping Rx syntax symbols to syntax characters.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 Each entry has the form (SYMBOL . CHAR), where SYMBOL is a valid
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 symbol in `(syntax SYMBOL)', and CHAR is the syntax character
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 corresponding to SYMBOL, as it would be used with \\s or \\S in
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 regular expressions.")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (defconst rx-categories
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 '((consonant . ?0)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (base-vowel . ?1)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (upper-diacritical-mark . ?2)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (lower-diacritical-mark . ?3)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (tone-mark . ?4)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (symbol . ?5)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (digit . ?6)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 (vowel-modifying-diacritical-mark . ?7)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (vowel-sign . ?8)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (semivowel-lower . ?9)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 (not-at-end-of-line . ?<)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (not-at-beginning-of-line . ?>)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (alpha-numeric-two-byte . ?A)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (chinse-two-byte . ?C)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (greek-two-byte . ?G)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (japanese-hiragana-two-byte . ?H)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (indian-two-byte . ?I)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (japanese-katakana-two-byte . ?K)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (korean-hangul-two-byte . ?N)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (cyrillic-two-byte . ?Y)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (ascii . ?a)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (arabic . ?b)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (chinese . ?c)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (ethiopic . ?e)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (greek . ?g)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (korean . ?h)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (indian . ?i)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 (japanese . ?j)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (japanese-katakana . ?k)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (latin . ?l)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (lao . ?o)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (tibetan . ?q)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (japanese-roman . ?r)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 (thai . ?t)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (vietnamese . ?v)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (hebrew . ?w)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (cyrillic . ?y)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (can-break . ?|))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 "Alist mapping symbols to category characters.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 Each entry has the form (SYMBOL . CHAR), where SYMBOL is a valid
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 symbol in `(category SYMBOL)', and CHAR is the category character
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 corresponding to SYMBOL, as it would be used with `\\c' or `\\C' in
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 regular expression strings.")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (defvar rx-greedy-flag t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "Non-nil means produce greedy regular expressions for `zero-or-one',
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 `zero-or-more', and `one-or-more'. Dynamically bound.")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (defun rx-info (op)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 "Return parsing/code generation info for OP.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 If OP is the space character ASCII 32, return info for the symbol `?'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 If OP is the character `?', return info for the symbol `??'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 See also `rx-constituents'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (cond ((eq op ? ) (setq op '\?))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 ((eq op ??) (setq op '\??)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (while (and (not (null op)) (symbolp op))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (setq op (cdr (assq op rx-constituents))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 op)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
247
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (defun rx-check (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 "Check FORM according to its car's parsing info."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (let* ((rx (rx-info (car form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (nargs (1- (length form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (min-args (nth 1 rx))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (max-args (nth 2 rx))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (type-pred (nth 3 rx)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (when (and (not (null min-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (< nargs min-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (error "Rx form `%s' requires at least %d args"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (car form) min-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (when (and (not (null max-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (> nargs max-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (error "Rx form `%s' accepts at most %d args"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (car form) max-args))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (when (not (null type-pred))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (dolist (sub-form (cdr form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (unless (funcall type-pred sub-form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (error "Rx form `%s' requires args satisfying `%s'"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (car form) type-pred))))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (defun rx-and (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 "Parse and produce code from FORM.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 FORM is of the form `(and FORM1 ...)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (rx-check form)
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
275 (concat "\\(?:"
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
276 (mapconcat
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
277 (function (lambda (x) (rx-to-string x 'no-group)))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
278 (cdr form) nil)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
279 "\\)"))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (defun rx-or (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 "Parse and produce code from FORM, which is `(or FORM1 ...)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (let ((all-args-strings t))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (dolist (arg (cdr form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (unless (stringp arg)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (setq all-args-strings nil)))
52971
d5c1eeaa97e2 (rx-or): Fix the case of "(rx (and ?a (or ?b ?c) ?d))".
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
289 (concat "\\(?:"
d5c1eeaa97e2 (rx-or): Fix the case of "(rx (and ?a (or ?b ?c) ?d))".
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
290 (if all-args-strings
d5c1eeaa97e2 (rx-or): Fix the case of "(rx (and ?a (or ?b ?c) ?d))".
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
291 (regexp-opt (cdr form))
d5c1eeaa97e2 (rx-or): Fix the case of "(rx (and ?a (or ?b ?c) ?d))".
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
292 (mapconcat #'rx-to-string (cdr form) "\\|"))
d5c1eeaa97e2 (rx-or): Fix the case of "(rx (and ?a (or ?b ?c) ?d))".
Eli Zaretskii <eliz@gnu.org>
parents: 52401
diff changeset
293 "\\)")))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (defun rx-quote-for-set (string)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 "Transform STRING for use in a character set.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 If STRING contains a `]', move it to the front.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 If STRING starts with a '^', move it to the end."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (when (string-match "\\`\\(\\(?:.\\|\n\\)+\\)\\]\\(\\(?:.\\|\n\\)\\)*\\'"
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 string)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (setq string (concat "]" (match-string 1 string)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (match-string 2 string))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (when (string-match "\\`^\\(\\(?:.\\|\n\\)+\\)\\'" string)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (setq string (concat (substring string 1) "^")))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 string)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (defun rx-check-any (arg)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 "Check arg ARG for Rx `any'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (cond ((integerp arg) t)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 ((and (stringp arg) (zerop (length arg)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (error "String arg for Rx `any' must not be empty"))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 ((stringp arg) t)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (error "Rx `any' requires string or character arg"))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (defun rx-any (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 "Parse and produce code from FORM, which is `(any STRING)'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 STRING is optional. If it is omitted, build a regexp that
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 matches anything."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (let ((arg (cadr form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (cond ((integerp arg)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (char-to-string arg))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 ((= (length arg) 1)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 arg)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (concat "[" (rx-quote-for-set (cadr form)) "]")))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (defun rx-check-not (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 "Check arguments of FORM. FORM is `(not ...)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (unless (or (memq form
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 '(digit control hex-digit blank graphic printing
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 alphanumeric letter ascii nonascii lower
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 punctuation space upper word))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (and (consp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (memq (car form) '(not any in syntax category:))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (error "Rx `not' syntax error: %s" form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 t)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (defun rx-not (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 "Parse and produce code from FORM. FORM is `(not ...)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (let ((result (rx-to-string (cadr form) 'no-group)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (cond ((string-match "\\`\\[^" result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (if (= (length result) 4)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (substring result 2 3)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (concat "[" (substring result 2))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 ((string-match "\\`\\[" result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (concat "[^" (substring result 1)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 ((string-match "\\`\\\\s." result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (concat "\\S" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 ((string-match "\\`\\\\S." result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (concat "\\s" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 ((string-match "\\`\\\\c." result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (concat "\\C" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 ((string-match "\\`\\\\C." result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (concat "\\c" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 ((string-match "\\`\\\\B" result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (concat "\\b" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 ((string-match "\\`\\\\b" result)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (concat "\\B" (substring result 2)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (concat "[^" result "]")))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (defun rx-repeat (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 "Parse and produce code from FORM.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 FORM is either `(repeat N FORM1)' or `(repeat N M FORM1)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (cond ((= (length form) 3)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (unless (and (integerp (nth 1 form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (> (nth 1 form) 0))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (error "Rx `repeat' requires positive integer first arg"))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (format "%s\\{%d\\}" (rx-to-string (nth 2 form)) (nth 1 form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 ((or (not (integerp (nth 2 form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (< (nth 2 form) 0)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (not (integerp (nth 1 form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (< (nth 1 form) 0)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (< (nth 2 form) (nth 1 form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (error "Rx `repeat' range error"))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (format "%s\\{%d,%d\\}" (rx-to-string (nth 3 form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (nth 1 form) (nth 2 form)))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (defun rx-submatch (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 "Parse and produce code from FORM, which is `(submatch ...)'."
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
393 (concat "\\("
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
394 (mapconcat (function (lambda (x) (rx-to-string x 'no-group)))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
395 (cdr form) nil)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
396 "\\)"))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (defun rx-kleene (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 "Parse and produce code from FORM.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 FORM is `(OP FORM1)', where OP is one of the `zero-or-one',
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
401 `zero-or-more' etc. operators.
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 If OP is one of `*', `+', `?', produce a greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 If OP is one of `*?', `+?', `??', produce a non-greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 If OP is anything else, produce a greedy regexp if `rx-greedy-flag'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 is non-nil."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (let ((suffix (cond ((memq (car form) '(* + ? )) "")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 ((memq (car form) '(*? +? ??)) "?")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (rx-greedy-flag "")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (t "?")))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (op (cond ((memq (car form) '(* *? 0+ zero-or-more)) "*")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 ((memq (car form) '(+ +? 1+ one-or-more)) "+")
48938
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
413 (t "?")))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
414 (result (rx-to-string (cadr form) 'no-group)))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
415 (if (not (rx-atomic-p result))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
416 (setq result (concat "\\(?:" result "\\)")))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
417 (concat result op suffix)))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
418
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
419 (defun rx-atomic-p (r)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
420 "Return non-nil if regexp string R is atomic.
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
421 An atomic regexp R is one such that a suffix operator
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
422 appended to R will apply to all of R. For example, \"a\"
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
423 \"[abc]\" and \"\\(ab\\|ab*c\\)\" are atomic and \"ab\",
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
424 \"[ab]c\", and \"ab\\|ab*c\" are not atomic.
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
425
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
426 This function may return false negatives, but it will not
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
427 return false positives. It is nevertheless useful in
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
428 situations where an efficiency shortcut can be taken iff a
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
429 regexp is atomic. The function can be improved to detect
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
430 more cases of atomic regexps. Presently, this function
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
431 detects the following categories of atomic regexp;
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
432
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
433 a group or shy group: \\(...\\)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
434 a character class: [...]
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
435 a single character: a
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
436
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
437 On the other hand, false negatives will be returned for
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
438 regexps that are atomic but end in operators, such as
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
439 \"a+\". I think these are rare. Probably such cases could
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
440 be detected without much effort. A guarantee of no false
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
441 negatives would require a theoretic specification of the set
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
442 of all atomic regexps."
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
443 (let ((l (length r)))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
444 (or (equal l 1)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
445 (and (>= l 6)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
446 (equal (substring r 0 2) "\\(")
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
447 (equal (substring r -2) "\\)"))
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
448 (and (>= l 2)
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
449 (equal (substring r 0 1) "[")
05f00479612c (rx-and): Generate a shy group.
Richard M. Stallman <rms@gnu.org>
parents: 47257
diff changeset
450 (equal (substring r -1) "]")))))
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (defun rx-syntax (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 "Parse and produce code from FORM, which is `(syntax SYMBOL)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (let ((syntax (assq (cadr form) rx-syntax)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (unless syntax
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (error "Unknown rx syntax `%s'" (cadr form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (format "\\s%c" (cdr syntax))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (defun rx-check-category (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 "Check the argument FORM of a `(category FORM)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (unless (or (integerp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (cdr (assq form rx-categories)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (error "Unknown category `%s'" form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 t)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
468
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (defun rx-category (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 "Parse and produce code from FORM, which is `(category SYMBOL ...)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (let ((char (if (integerp (cadr form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (cadr form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (cdr (assq (cadr form) rx-categories)))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (format "\\c%c" char)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (defun rx-eval (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 "Parse and produce code from FORM, which is `(eval FORM)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (rx-to-string (eval (cadr form))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (defun rx-greedy (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 "Parse and produce code from FORM. If FORM is '(minimal-match
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 FORM1)', non-greedy versions of `*', `+', and `?' operators will be
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 used in FORM1. If FORM is '(maximal-match FORM1)', greedy operators
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 will be used."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (let ((rx-greedy-flag (eq (car form) 'maximal-match)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (rx-to-string (cadr form))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (defun rx-regexp (form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 "Parse and produce code from FORM, which is `(regexp STRING)'."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (rx-check form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (concat "\\(?:" (cadr form) "\\)"))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 ;;;###autoload
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (defun rx-to-string (form &optional no-group)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 "Parse and produce code for regular expression FORM.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 FORM is a regular expression in sexp form.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 NO-GROUP non-nil means don't put shy groups around the result."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (cond ((stringp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (regexp-quote form))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 ((integerp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (regexp-quote (char-to-string form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 ((symbolp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (let ((info (rx-info form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (cond ((stringp info)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 info)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 ((null info)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (error "Unknown Rx form `%s'" form))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
516 (t
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (funcall (nth 0 info) form)))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 ((consp form)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (let ((info (rx-info (car form))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (unless (consp info)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (error "Unknown Rx form `%s'" (car form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (let ((result (funcall (nth 0 info) form)))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (if (or no-group (string-match "\\`\\\\[(]" result))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 result
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (concat "\\(?:" result "\\)")))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (t
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (error "Rx syntax error at `%s'" form))))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 ;;;###autoload
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (defmacro rx (regexp)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 "Translate a regular expression REGEXP in sexp form to a regexp string.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 See also `rx-to-string' for how to do such a translation at run-time.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 The following are valid subforms of regular expressions in sexp
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 notation.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 STRING
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 matches string STRING literally.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 CHAR
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 matches character CHAR literally.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 `not-newline'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 matches any character except a newline.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 .
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 `anything'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 matches any character
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 `(any SET)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 matches any character in SET. SET may be a character or string.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 Ranges of characters can be specified as `A-Z' in strings.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
554 '(in SET)'
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 like `any'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 `(not (any SET))'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 matches any character not in SET
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 `line-start'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 matches the empty string, but only at the beginning of a line
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 in the text being matched
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 `line-end'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 is similar to `line-start' but matches only at the end of a line
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 `string-start'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 matches the empty string, but only at the beginning of the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 string being matched against.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 `string-end'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 matches the empty string, but only at the end of the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 string being matched against.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 `buffer-start'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 matches the empty string, but only at the beginning of the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 buffer being matched against.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 `buffer-end'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 matches the empty string, but only at the end of the
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 buffer being matched against.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 `point'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 matches the empty string, but only at point.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 `word-start'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 matches the empty string, but only at the beginning or end of a
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 word.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 `word-end'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 matches the empty string, but only at the end of a word.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 `word-boundary'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 matches the empty string, but only at the beginning or end of a
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 word.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 `(not word-boundary)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 matches the empty string, but not at the beginning or end of a
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 word.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 `digit'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 matches 0 through 9.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 `control'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 matches ASCII control characters.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 `hex-digit'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 matches 0 through 9, a through f and A through F.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 `blank'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 matches space and tab only.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 `graphic'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 matches graphic characters--everything except ASCII control chars,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 space, and DEL.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 `printing'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 matches printing characters--everything except ASCII control chars
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 and DEL.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 `alphanumeric'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 matches letters and digits. (But at present, for multibyte characters,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 it matches anything that has word syntax.)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 `letter'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 matches letters. (But at present, for multibyte characters,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 it matches anything that has word syntax.)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 `ascii'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 matches ASCII (unibyte) characters.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 `nonascii'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 matches non-ASCII (multibyte) characters.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 `lower'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 matches anything lower-case.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 `upper'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 matches anything upper-case.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 `punctuation'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 matches punctuation. (But at present, for multibyte characters,
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 it matches anything that has non-word syntax.)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 `space'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 matches anything that has whitespace syntax.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 `word'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 matches anything that has word syntax.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 `(syntax SYNTAX)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 matches a character with syntax SYNTAX. SYNTAX must be one
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 of the following symbols.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 `whitespace' (\\s- in string notation)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 `punctuation' (\\s.)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 `word' (\\sw)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 `symbol' (\\s_)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 `open-parenthesis' (\\s()
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 `close-parenthesis' (\\s))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 `expression-prefix' (\\s')
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 `string-quote' (\\s\")
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 `paired-delimiter' (\\s$)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 `escape' (\\s\\)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 `character-quote' (\\s/)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 `comment-start' (\\s<)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 `comment-end' (\\s>)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 `(not (syntax SYNTAX))'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 matches a character that has not syntax SYNTAX.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 `(category CATEGORY)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 matches a character with category CATEGORY. CATEGORY must be
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 either a character to use for C, or one of the following symbols.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 `consonant' (\\c0 in string notation)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 `base-vowel' (\\c1)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 `upper-diacritical-mark' (\\c2)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 `lower-diacritical-mark' (\\c3)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 `tone-mark' (\\c4)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 `symbol' (\\c5)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 `digit' (\\c6)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 `vowel-modifying-diacritical-mark' (\\c7)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 `vowel-sign' (\\c8)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 `semivowel-lower' (\\c9)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 `not-at-end-of-line' (\\c<)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 `not-at-beginning-of-line' (\\c>)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 `alpha-numeric-two-byte' (\\cA)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 `chinse-two-byte' (\\cC)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 `greek-two-byte' (\\cG)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 `japanese-hiragana-two-byte' (\\cH)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 `indian-tow-byte' (\\cI)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 `japanese-katakana-two-byte' (\\cK)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 `korean-hangul-two-byte' (\\cN)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 `cyrillic-two-byte' (\\cY)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 `ascii' (\\ca)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 `arabic' (\\cb)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 `chinese' (\\cc)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 `ethiopic' (\\ce)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 `greek' (\\cg)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 `korean' (\\ch)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 `indian' (\\ci)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 `japanese' (\\cj)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 `japanese-katakana' (\\ck)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 `latin' (\\cl)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 `lao' (\\co)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 `tibetan' (\\cq)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 `japanese-roman' (\\cr)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 `thai' (\\ct)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 `vietnamese' (\\cv)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 `hebrew' (\\cw)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 `cyrillic' (\\cy)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 `can-break' (\\c|)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 `(not (category CATEGORY))'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 matches a character that has not category CATEGORY.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 `(and SEXP1 SEXP2 ...)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 matches what SEXP1 matches, followed by what SEXP2 matches, etc.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 `(submatch SEXP1 SEXP2 ...)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 like `and', but makes the match accessible with `match-end',
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 `match-beginning', and `match-string'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 `(group SEXP1 SEXP2 ...)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 another name for `submatch'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 `(or SEXP1 SEXP2 ...)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 matches anything that matches SEXP1 or SEXP2, etc. If all
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 args are strings, use `regexp-opt' to optimize the resulting
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 regular expression.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 `(minimal-match SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 produce a non-greedy regexp for SEXP. Normally, regexps matching
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 zero or more occurrances of something are \"greedy\" in that they
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 match as much as they can, as long as the overall regexp can
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 still match. A non-greedy regexp matches as little as possible.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 `(maximal-match SEXP)'
47257
14ef33c0a704 (rx): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 39516
diff changeset
740 produce a greedy regexp for SEXP. This is the default.
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 `(zero-or-more SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 matches zero or more occurrences of what SEXP matches.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 `(0+ SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 like `zero-or-more'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 `(* SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 like `zero-or-more', but always produces a greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 `(*? SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 like `zero-or-more', but always produces a non-greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 `(one-or-more SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 matches one or more occurrences of A.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
756
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 `(1+ SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 like `one-or-more'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 `(+ SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 like `one-or-more', but always produces a greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 `(+? SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 like `one-or-more', but always produces a non-greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 `(zero-or-one SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 matches zero or one occurrences of A.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48938
diff changeset
768
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 `(optional SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 like `zero-or-one'.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 `(? SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 like `zero-or-one', but always produces a greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 `(?? SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 like `zero-or-one', but always produces a non-greedy regexp.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 `(repeat N SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 matches N occurrences of what SEXP matches.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 `(repeat N M SEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 matches N to M occurrences of what SEXP matches.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 `(eval FORM)'
47257
14ef33c0a704 (rx): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 39516
diff changeset
785 evaluate FORM and insert result. If result is a string,
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 `regexp-quote' it.
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 `(regexp REGEXP)'
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 include REGEXP in string notation in the result."
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 `(rx-to-string ',regexp))
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 (provide 'rx)
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
796 ;;; arch-tag: 12d01a63-0008-42bb-ab8c-1c7d63be370b
39516
9160fa3bfe4b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 ;;; rx.el ends here