From: morioka Date: Sat, 16 Jan 1999 12:56:37 +0000 (+0000) Subject: (std11-lexical-analyzers): New user option. X-Git-Tag: flim-1_12-199901161900~14 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ede0dee7d5f79dd00094ce9a53e82386d5ec53cf;p=elisp%2Fflim.git (std11-lexical-analyzers): New user option. (std11-lexical-analyze): New implementation; refer `std11-lexical-analyzers'. --- diff --git a/std11.el b/std11.el index b9d6817..31c7830 100644 --- a/std11.el +++ b/std11.el @@ -261,6 +261,25 @@ If BOUNDARY is not nil, it is used as message header separator." ;;; @ lexical analyze ;;; +(defcustom std11-lexical-analyzers + '(std11-analyze-quoted-string + std11-analyze-domain-literal + std11-analyze-comment + std11-analyze-spaces + std11-analyze-special + std11-analyze-atom) + "*List of functions to return result of lexical analyze. +Each function must have two arguments: STRING and START. +STRING is the target string to be analyzed. +START is start position of STRING to analyze. + +Previous function is preferred to next function. If a function +returns nil, next function is used. Otherwise the return value will +be the result." + :group 'news + :group 'mail + :type '(repeat function)) + (eval-and-compile (defconst std11-space-char-list '(? ?\t ?\n)) (defconst std11-special-char-list '(?\] ?\[ @@ -369,14 +388,14 @@ If BOUNDARY is not nil, it is used as message header separator." dest ret) (while (< start len) (setq ret - (or (std11-analyze-quoted-string string start) - (std11-analyze-domain-literal string start) - (std11-analyze-comment string start) - (std11-analyze-spaces string start) - (std11-analyze-special string start) - (std11-analyze-atom string start) - (cons '(error) (1+ len)) - )) + (let ((rest std11-lexical-analyzers) + func r) + (while (and (setq func (car rest)) + (null (setq r (funcall func string start)))) + (setq rest (cdr rest))) + (or r + (list (cons 'error (substring string start)) (1+ len))) + )) (setq dest (cons (car ret) dest) start (cdr ret)) )