(std11-analyze-domain-literal): New function.
[elisp/apel.git] / std11-parse.el
index aaea3da..34d22d3 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author:   MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Keywords: mail, news, RFC 822, STD 11
-;; Version: $Id: std11-parse.el,v 0.2 1996-08-28 17:06:45 morioka Exp $
+;; Version: $Id: std11-parse.el,v 0.6 1996-08-28 17:35:10 morioka Exp $
 
 ;; This file is part of tl (Tiny Library).
 
@@ -34,6 +34,8 @@
 (defconst std11-space-chars " \t\n")
 (defconst std11-spaces-regexp (concat "^[" std11-space-chars "]+"))
 (defconst std11-special-chars "][()<>@,;:\\<>.\"")
+(defconst std11-atom-regexp
+  (concat "^[^" std11-special-chars std11-space-chars "]+"))
 
 (defun std11-analyze-spaces (str)
   (if (string-match std11-spaces-regexp str)
            (substring str 1)
            )))
 
+(defun std11-analyze-atom (str)
+  (if (string-match std11-atom-regexp str)
+      (let ((end (match-end 0)))
+       (cons (cons 'atom (substring str 0 end))
+             (substring str end)
+             ))))
+
+(defun std11-analyze-enclosure (str type open close)
+  (let ((len (length str)))
+    (if (and (> len 0)
+            (eq (aref str 0) open))
+       (let ((i 1) chr dest)
+         (catch 'tag
+           (while (< i len)
+             (setq chr (aref str i))
+             (cond ((eq chr ?\\)
+                    (setq i (1+ i))
+                    (if (>= i len)
+                        (throw 'tag nil)
+                      )
+                    (setq dest (concat dest (char-to-string (aref str i))))
+                    )
+                   ((eq chr close)
+                    (throw 'tag
+                           (cons (cons type dest) (substring str (1+ i)))
+                           )
+                    )
+                   (t
+                    (setq dest (concat dest (char-to-string (aref str i))))
+                    ))
+             (setq i (1+ i))
+             ))))))
+
+(defun std11-analyze-quoted-string (str)
+  (std11-analyze-enclosure str 'quoted-string ?\" ?\")
+  )
+
+(defun std11-analyze-domain-literal (str)
+  (std11-analyze-enclosure str 'domain-literal ?\[ ?\])
+  )
+
 
 ;;; @ end
 ;;;