Delete mmgeneric.el.
[elisp/flim.git] / ew-scan-u.el
1 (require 'lex)
2 (require 'automata)
3 (require 'ew-data)
4 (require 'ew-parse)
5 (provide 'ew-scan-u)
6
7 (defmacro ew-scan-unstructured (scan col str)
8   `(let ((res (ew-make-anchor col str))
9          (p 0)
10          (q (length str))
11          r
12          type)
13      (while (< p q)
14        (setq r p)
15        (setq
16         type
17         (,scan
18          str p q
19          ([" \t"] 'ew:us-wsp)
20          (((* [^ " \t\r"])
21            (* (+ ?\r) [^ " \t\r\n"] (* [^ " \t\r"]))
22            (* ?\r)
23            (?\r ?\n [" \t"]))
24           (when (< r (- p 3))
25             (ew-add-frag res r (- p 3) 'ew:us-texts)
26             (setq r (- p 3)))
27           'ew:us-fold)
28          (((* [^ " \t\r"])
29            (* (+ ?\r) [^ " \t\r\n"] (* [^ " \t\r"]))
30            (* ?\r)
31            (?\r ?\n [^ " \t"]))
32           (when (< r (- p 3))
33             (ew-add-frag res r (- p 3) 'ew:us-texts)
34             (setq r (- p 3)))
35           (setq p q) 'ew:*err*)
36          (((* [^ " \t\r"])
37            (* (+ ?\r) [^ " \t\r\n"] (* [^ " \t\r"]))
38            (* ?\r))
39           (if (< r p)
40               'ew:us-texts
41             (progn (setq p q) 'ew:*err*)))))
42        (ew-add-frag res r p type))
43      (ew-terminate res)
44      res))
45
46 (defun ew-scan-unibyte-unstructured (col str)
47   (ew-scan-unstructured lex-scan-unibyte col str))
48 (defun ew-scan-multibyte-unstructured (col str)
49   (ew-scan-unstructured lex-scan-multibyte col str))
50
51 '(      
52 (npp
53  (mapcar
54   (lambda (frag) (cons (get frag 'type) (symbol-name frag)))
55   (ew-frag-list
56    (ew-scan-unibyte-unstructured
57     0 " Hello! =?US-ASCII?Q?Hello!?="))))
58
59 (npp
60  (mapcar
61   (lambda (frag) (cons (get frag 'type) (symbol-name frag)))
62   (ew-frag-list
63    (ew-scan-unibyte-unstructured
64     0 " \r\na"))))
65
66 )