From ede0dee7d5f79dd00094ce9a53e82386d5ec53cf Mon Sep 17 00:00:00 2001 From: morioka Date: Sat, 16 Jan 1999 12:56:37 +0000 Subject: [PATCH] (std11-lexical-analyzers): New user option. (std11-lexical-analyze): New implementation; refer `std11-lexical-analyzers'. --- std11.el | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) 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)) ) -- 1.7.10.4