78 |
;; (and line-start ?\n))) |
;; (and line-start ?\n))) |
79 |
;; |
;; |
80 |
;; "\\$[I]d: [^ ]+ \\([^ ]+\\) " |
;; "\\$[I]d: [^ ]+ \\([^ ]+\\) " |
81 |
;; (rx (and "$Id": " |
;; (rx (and "$Id": " |
82 |
;; (1+ (not (in " "))) |
;; (1+ (not (in " "))) |
83 |
;; " " |
;; " " |
84 |
;; (submatch (1+ (not (in " ")))) |
;; (submatch (1+ (not (in " ")))) |
85 |
;; " "))) |
;; " "))) |
90 |
;; etc. |
;; etc. |
91 |
|
|
92 |
;;; History: |
;;; History: |
93 |
;; |
;; |
94 |
|
|
95 |
;;; Code: |
;;; Code: |
96 |
|
|
244 |
(while (and (not (null op)) (symbolp op)) |
(while (and (not (null op)) (symbolp op)) |
245 |
(setq op (cdr (assq op rx-constituents)))) |
(setq op (cdr (assq op rx-constituents)))) |
246 |
op) |
op) |
247 |
|
|
248 |
|
|
249 |
(defun rx-check (form) |
(defun rx-check (form) |
250 |
"Check FORM according to its car's parsing info." |
"Check FORM according to its car's parsing info." |
390 |
(defun rx-kleene (form) |
(defun rx-kleene (form) |
391 |
"Parse and produce code from FORM. |
"Parse and produce code from FORM. |
392 |
FORM is `(OP FORM1)', where OP is one of the `zero-or-one', |
FORM is `(OP FORM1)', where OP is one of the `zero-or-one', |
393 |
`zero-or-more' etc. operators. |
`zero-or-more' etc. operators. |
394 |
If OP is one of `*', `+', `?', produce a greedy regexp. |
If OP is one of `*', `+', `?', produce a greedy regexp. |
395 |
If OP is one of `*?', `+?', `??', produce a non-greedy regexp. |
If OP is one of `*?', `+?', `??', produce a non-greedy regexp. |
396 |
If OP is anything else, produce a greedy regexp if `rx-greedy-flag' |
If OP is anything else, produce a greedy regexp if `rx-greedy-flag' |
403 |
(op (cond ((memq (car form) '(* *? 0+ zero-or-more)) "*") |
(op (cond ((memq (car form) '(* *? 0+ zero-or-more)) "*") |
404 |
((memq (car form) '(+ +? 1+ one-or-more)) "+") |
((memq (car form) '(+ +? 1+ one-or-more)) "+") |
405 |
(t "?")))) |
(t "?")))) |
406 |
(format "\\(?:%s\\)%s%s" (rx-to-string (cadr form) 'no-group) |
(format "\\(?:%s\\)%s%s" (rx-to-string (cadr form) 'no-group) |
407 |
op suffix))) |
op suffix))) |
408 |
|
|
409 |
|
|
422 |
(cdr (assq form rx-categories))) |
(cdr (assq form rx-categories))) |
423 |
(error "Unknown category `%s'" form)) |
(error "Unknown category `%s'" form)) |
424 |
t) |
t) |
425 |
|
|
426 |
|
|
427 |
(defun rx-category (form) |
(defun rx-category (form) |
428 |
"Parse and produce code from FORM, which is `(category SYMBOL ...)'." |
"Parse and produce code from FORM, which is `(category SYMBOL ...)'." |
470 |
info) |
info) |
471 |
((null info) |
((null info) |
472 |
(error "Unknown Rx form `%s'" form)) |
(error "Unknown Rx form `%s'" form)) |
473 |
(t |
(t |
474 |
(funcall (nth 0 info) form))))) |
(funcall (nth 0 info) form))))) |
475 |
((consp form) |
((consp form) |
476 |
(let ((info (rx-info (car form)))) |
(let ((info (rx-info (car form)))) |
508 |
matches any character in SET. SET may be a character or string. |
matches any character in SET. SET may be a character or string. |
509 |
Ranges of characters can be specified as `A-Z' in strings. |
Ranges of characters can be specified as `A-Z' in strings. |
510 |
|
|
511 |
'(in SET)' |
'(in SET)' |
512 |
like `any'. |
like `any'. |
513 |
|
|
514 |
`(not (any SET))' |
`(not (any SET))' |
694 |
still match. A non-greedy regexp matches as little as possible. |
still match. A non-greedy regexp matches as little as possible. |
695 |
|
|
696 |
`(maximal-match SEXP)' |
`(maximal-match SEXP)' |
697 |
produce a greedy regexp for SEXP. This is the default. |
produce a greedy regexp for SEXP. This is the default. |
698 |
|
|
699 |
`(zero-or-more SEXP)' |
`(zero-or-more SEXP)' |
700 |
matches zero or more occurrences of what SEXP matches. |
matches zero or more occurrences of what SEXP matches. |
710 |
|
|
711 |
`(one-or-more SEXP)' |
`(one-or-more SEXP)' |
712 |
matches one or more occurrences of A. |
matches one or more occurrences of A. |
713 |
|
|
714 |
`(1+ SEXP)' |
`(1+ SEXP)' |
715 |
like `one-or-more'. |
like `one-or-more'. |
716 |
|
|
722 |
|
|
723 |
`(zero-or-one SEXP)' |
`(zero-or-one SEXP)' |
724 |
matches zero or one occurrences of A. |
matches zero or one occurrences of A. |
725 |
|
|
726 |
`(optional SEXP)' |
`(optional SEXP)' |
727 |
like `zero-or-one'. |
like `zero-or-one'. |
728 |
|
|
739 |
matches N to M occurrences of what SEXP matches. |
matches N to M occurrences of what SEXP matches. |
740 |
|
|
741 |
`(eval FORM)' |
`(eval FORM)' |
742 |
evaluate FORM and insert result. If result is a string, |
evaluate FORM and insert result. If result is a string, |
743 |
`regexp-quote' it. |
`regexp-quote' it. |
744 |
|
|
745 |
`(regexp REGEXP)' |
`(regexp REGEXP)' |