(put 'ew-lf-line-generic 'lisp-indent-function 1)
(put 'ew-lf-line-convert 'lisp-indent-function 1)
+(defun ew-tab-to-space (str)
+ (let ((i 0) (j 0) (l (length str)) result)
+ (while (< j l)
+ (when (equal (aref str j) ?\t)
+ (setq result (ew-rcons*
+ result
+ (substring str i j)
+ " ")
+ i j))
+ (setq j (1+ j)))
+ (when (< i l)
+ (setq result (ew-rcons*
+ result
+ (substring str i))))
+ (apply 'concat (nreverse result))))
+
(defun ew-lf-to-crlf (str)
(let ((i 0) (j 0) (l (length str)) result)
(while (< j l)
(defun ew-cut-cr (str) (ew-cut-generic str '(?\r)))
(defun ew-cut-lf (str) (ew-cut-generic str '(?\n)))
-(defmacro ew-crlf-line-generic-define ()
+(defmacro ew-crlf-generic-define ()
(let ((str (make-symbol "str"))
(others-fun (make-symbol "others-fun"))
(fold-fun (make-symbol "fold-fun"))
- (crlf-fun (make-symbol "crlf-fun"))
- (bare-cr-fun (make-symbol "bare-cr-fun"))
- (bare-lf-fun (make-symbol "bare-lf-fun"))
+ (nl-fun (make-symbol "nl-fun"))
+ (cr-fun (make-symbol "cr-fun"))
+ (lf-fun (make-symbol "lf-fun"))
(p (make-symbol "p"))
(q (make-symbol "q"))
(r (make-symbol "r")))
- `(defun ew-crlf-line-generic
- (,str ,others-fun ,fold-fun ,crlf-fun ,bare-cr-fun ,bare-lf-fun)
+ `(defun ew-crlf-generic
+ (,str ,others-fun ,fold-fun ,nl-fun ,cr-fun ,lf-fun)
(let ((,p 0) (,q (length ,str)) ,r)
(while (< ,p ,q)
(setq ,r ,p)
(lex-scan-unibyte ,str ,p ,q
((+ [^ "\r\n"]) (when ,others-fun (funcall ,others-fun ,r ,p)))
((?\r ?\n [" \t"]) (when ,fold-fun (funcall ,fold-fun ,r ,p)))
- ((?\r ?\n) (when ,crlf-fun (funcall ,crlf-fun ,r ,p)))
- ((?\r) (when ,bare-cr-fun (funcall ,bare-cr-fun ,r ,p)))
- ((?\n) (when ,bare-lf-fun (funcall ,bare-lf-fun ,r ,p)))
+ ((?\r ?\n) (when ,nl-fun (funcall ,nl-fun ,r ,p)))
+ ((?\r) (when ,cr-fun (funcall ,cr-fun ,r ,p)))
+ ((?\n) (when ,lf-fun (funcall ,lf-fun ,r ,p)))
(() (error "something wrong"))))
,q))))
+(ew-crlf-generic-define)
+(defmacro ew-crlf-line-generic-define ()
+ (let ((str (make-symbol "str"))
+ (others-fun (make-symbol "others-fun"))
+ (fold-fun (make-symbol "fold-fun"))
+ (nl-fun (make-symbol "nl-fun"))
+ (p (make-symbol "p"))
+ (q (make-symbol "q"))
+ (r (make-symbol "r")))
+ `(defun ew-crlf-line-generic
+ (,str ,others-fun ,fold-fun ,nl-fun)
+ (let ((,p 0) (,q (length ,str)) ,r)
+ (while (< ,p ,q)
+ (setq ,r ,p)
+ (lex-scan-unibyte ,str ,p ,q
+ (() (error "something wrong"))
+ (((* [^ "\r\n"])
+ (* (+ ?\r) [^ "\r\n"] (* [^ "\r"]))
+ (* ?\r)
+ (?\r ?\n [" \t"]))
+ (when (and ,others-fun (< ,r (- ,p 3))) (funcall ,others-fun ,r (- ,p 3)))
+ (when ,fold-fun (funcall ,fold-fun (- ,p 3) ,p)))
+ (((* [^ "\r\n"])
+ (* (+ ?\r) [^ "\r\n"] (* [^ "\r"]))
+ (* ?\r)
+ (?\r ?\n))
+ (when (and ,others-fun (< ,r (- ,p 2))) (funcall ,others-fun ,r (- ,p 2)))
+ (when ,nl-fun (funcall ,nl-fun (- ,p 2) ,p)))
+ (((* [^ "\r\n"])
+ (* (+ ?\r) [^ "\r\n"] (* [^ "\r"]))
+ (* ?\r))
+ (when ,others-fun (funcall ,others-fun ,r ,p)))))
+ ,q))))
(ew-crlf-line-generic-define)
-(defmacro ew-crlf-line-convert-define ()
+(defmacro ew-lf-generic-define ()
(let ((str (make-symbol "str"))
(others-fun (make-symbol "others-fun"))
(fold-fun (make-symbol "fold-fun"))
- (crlf-fun (make-symbol "crlf-fun"))
- (bare-cr-fun (make-symbol "bare-cr-fun"))
- (bare-lf-fun (make-symbol "bare-lf-fun"))
- (index (make-symbol "index"))
- (result (make-symbol "result"))
- (start (make-symbol "starx"))
- (end (make-symbol "end")))
- `(defun ew-crlf-line-convert
- (,str ,others-fun ,fold-fun ,crlf-fun ,bare-cr-fun ,bare-lf-fun)
- (let ((,index 0) ,result)
- (when (> (ew-crlf-line-generic
- ,str
- ,@(mapcar
- (lambda (fun)
- `(when ,fun
- (lambda (,start ,end)
- (when (< ,index ,start)
- (setq ,result
- (ew-rcons* ,result
- (substring ,str ,index ,start))))
- (setq ,result
- (ew-rcons* ,result
- (funcall ,fun
- (substring ,str ,start ,end)))
- ,index ,end))))
- (list others-fun fold-fun crlf-fun bare-cr-fun bare-lf-fun)))
- ,index)
- (setq ,result
- (ew-rcons* ,result
- (substring ,str ,index))))
- (apply 'concat (nreverse ,result))))))
-
-(ew-crlf-line-convert-define)
+ (nl-fun (make-symbol "nl-fun"))
+ (cr-fun (make-symbol "cr-fun"))
+ (p (make-symbol "p"))
+ (q (make-symbol "q"))
+ (r (make-symbol "r")))
+ `(defun ew-lf-generic
+ (,str ,others-fun ,fold-fun ,nl-fun ,cr-fun)
+ (let ((,p 0) (,q (length ,str)) ,r)
+ (while (< ,p ,q)
+ (setq ,r ,p)
+ (lex-scan-unibyte ,str ,p ,q
+ ((+ [^ "\r\n"]) (when ,others-fun (funcall ,others-fun ,r ,p)))
+ ((?\n [" \t"]) (when ,fold-fun (funcall ,fold-fun ,r ,p)))
+ ((?\n) (when ,nl-fun (funcall ,nl-fun ,r ,p)))
+ ((?\r) (when ,cr-fun (funcall ,cr-fun ,r ,p)))
+ (() (error "something wrong"))))
+ ,q))))
+(ew-lf-generic-define)
(defmacro ew-lf-line-generic-define ()
(let ((str (make-symbol "str"))
(others-fun (make-symbol "others-fun"))
(fold-fun (make-symbol "fold-fun"))
- (lf-fun (make-symbol "lf-fun"))
+ (nl-fun (make-symbol "nl-fun"))
(p (make-symbol "p"))
(q (make-symbol "q"))
(r (make-symbol "r")))
`(defun ew-lf-line-generic
- (,str ,others-fun ,fold-fun ,lf-fun)
+ (,str ,others-fun ,fold-fun ,nl-fun)
(let ((,p 0) (,q (length ,str)) ,r)
(while (< ,p ,q)
(setq ,r ,p)
(lex-scan-unibyte ,str ,p ,q
- ((+ [^ "\n"]) (when ,others-fun (funcall ,others-fun ,r ,p)))
- ((?\n [" \t"]) (when ,fold-fun (funcall ,fold-fun ,r ,p)))
- ((?\n) (when ,lf-fun (funcall ,lf-fun ,r ,p)))
- (() (error "something wrong"))))
+ (() (error "something wrong"))
+ ((+ [^ "\n"])
+ (when ,others-fun (funcall ,others-fun ,r ,p)))
+ ((?\n [" \t"])
+ (when ,fold-fun (funcall ,fold-fun ,r ,p)))
+ (?\n
+ (when ,nl-fun (funcall ,nl-fun ,r ,p)))))
,q))))
-
(ew-lf-line-generic-define)
-(defmacro ew-lf-line-convert-define ()
+(defmacro ew-generic-convert-define (name generic &rest funcs)
(let ((str (make-symbol "str"))
- (others-fun (make-symbol "others-fun"))
- (fold-fun (make-symbol "fold-fun"))
- (lf-fun (make-symbol "lf-fun"))
+ (funcs-vars (mapcar (lambda (func) (make-symbol (symbol-name func))) funcs))
(index (make-symbol "index"))
(result (make-symbol "result"))
+ (tmp (make-symbol "tmp"))
(start (make-symbol "starx"))
(end (make-symbol "end")))
- `(defun ew-lf-line-convert
- (,str ,others-fun ,fold-fun ,lf-fun)
- (let ((,index 0) ,result)
- (when (> (ew-lf-line-generic
- ,str
- ,@(mapcar
- (lambda (fun)
- `(when ,fun
- (lambda (,start ,end)
- (when (< ,index ,start)
- (setq ,result
- (ew-rcons* ,result
- (substring ,str ,index ,start))))
- (setq ,result
- (ew-rcons* ,result
- (funcall ,fun
- (substring ,str ,start ,end)))
- ,index ,end))))
- (list others-fun fold-fun lf-fun)))
+ `(defun ,name
+ (,str ,@funcs-vars)
+ (let ((,index 0) ,result ,tmp)
+ (when (> (,generic
+ ,str
+ ,@(mapcar
+ (lambda (fun)
+ `(when ,fun
+ (lambda (,start ,end)
+ (setq ,tmp (funcall ,fun (substring ,str ,start ,end)))
+ (when ,tmp
+ (when (< ,index ,start)
+ (setq ,result
+ (ew-rcons* ,result
+ (substring ,str ,index ,start))))
+ (setq ,result (ew-rcons* ,result ,tmp)
+ ,index ,end)))))
+ funcs-vars))
,index)
(setq ,result
(ew-rcons* ,result
(substring ,str ,index))))
(apply 'concat (nreverse ,result))))))
+(ew-generic-convert-define ew-crlf-convert ew-crlf-generic others-fun fold-fun nl-fun cr-fun lf-fun)
+(ew-generic-convert-define ew-crlf-line-convert ew-crlf-line-generic others-fun fold-fun nl-fun)
+(ew-generic-convert-define ew-lf-convert ew-lf-generic others-fun fold-fun nl-fun cr-fun)
+(ew-generic-convert-define ew-lf-line-convert ew-lf-line-generic others-fun fold-fun nl-fun)
+
+(defmacro ew-fold-define (name convert nl)
+ `(defun ,name (str start-column line-length)
+ (let ((column start-column))
+ (,convert str
+ (lambda (line)
+ (let ((start 0)
+ (end (length line))
+ result tmp fold width)
+ (while (and (< start end)
+ (progn
+ (when (<= column 1)
+ (setq tmp (sref line start)
+ result (ew-rcons* result (char-to-string tmp))
+ column (+ column (char-width tmp))
+ start (char-next-index tmp start)))
+ (string-match "[ \t]" line start)))
+ (setq tmp (substring line start (match-beginning 0))
+ width (string-width tmp)
+ result (ew-rcons* result tmp)
+ column (+ column width)
+ start (match-beginning 0))
+ (if (<= line-length column)
+ (progn
+ (when (and fold (not (= line-length column)))
+ (setcdr fold (cons (car fold) (cdr fold)))
+ (setcar fold ,nl)
+ (setq column (+ width
+ (if (eq (cdr result) fold)
+ 0
+ (string-width (cadr result))))))
+ (if (<= line-length column)
+ (setq result (ew-rcons* result ,nl)
+ column 0
+ fold nil)
+ (setq fold result)))
+ (setq fold result))
+ (setq tmp (sref line (match-beginning 0))
+ result (ew-rcons* result (char-to-string tmp))
+ column (+ column (char-width tmp))
+ start (match-end 0)))
+ (when (< start end)
+ (setq tmp (substring line start)
+ result (ew-rcons* result tmp)
+ column (+ column (string-width tmp))))
+ (when (and (< line-length column) fold)
+ (setcdr fold (cons (car fold) (cdr fold)))
+ (setcar fold ,nl))
+ (apply 'concat (nreverse result))))
+ (lambda (fold) (setq column 1) nil)
+ (lambda (nl) (setq column 0) nil)))))
+
+(ew-fold-define ew-crlf-fold ew-crlf-line-convert "\r\n")
+(ew-fold-define ew-lf-fold ew-crlf-line-convert "\n")
+
+(defun ew-crlf-refold (string start-column line-length)
+ (ew-crlf-fold (ew-crlf-unfold string) start-column line-length))
-(ew-lf-line-convert-define)
+(defun ew-lf-refold (string start-column line-length)
+ (ew-lf-fold (ew-lf-unfold string) start-column line-length))
(defconst ew:reduction-table
(vector
'()
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(accept $1)))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 1 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 2 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 2 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 3 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 3 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 4 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 4 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 5 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 6 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($4 (aref stack (- sp 1)))
($3 (aref stack (- sp 3)))
($2 (aref stack (- sp 5)))
($1 (aref stack (- sp 7))))
(lr-push stack (- sp 8) 7 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 7 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 8 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 8 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 9 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($4 (aref stack (- sp 1)))
($3 (aref stack (- sp 3)))
($2 (aref stack (- sp 5)))
($1 (aref stack (- sp 7))))
(lr-push stack (- sp 8) 10 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 11 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($5 (aref stack (- sp 1)))
($4 (aref stack (- sp 3)))
($3 (aref stack (- sp 5)))
($2 (aref stack (- sp 7)))
($1 (aref stack (- sp 9))))
(lr-push stack (- sp 10) 11 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 12 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 12 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 13 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 13 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 13 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 14 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 14 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 15 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 15 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 16 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 17 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 18 goto-table (ew-mark-phrase (car $1) (cdr $1)))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 19 goto-table $1)))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 19 goto-table (cons (car $1) (cdr $2)))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 20 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 21 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($4 (aref stack (- sp 1)))
($3 (aref stack (- sp 3)))
($2 (aref stack (- sp 5)))
($1 (aref stack (- sp 7))))
(lr-push stack (- sp 8) 21 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($4 (aref stack (- sp 1)))
($3 (aref stack (- sp 3)))
($2 (aref stack (- sp 5)))
($1 (aref stack (- sp 7))))
(lr-push stack (- sp 8) 22 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 23 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 23 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 24 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 24 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 25 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 26 goto-table $1)))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 26 goto-table $1)))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 27 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 28 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 28 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 29 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 29 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 30 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 30 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 31 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 31 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($1 (aref stack (- sp 1))))
(lr-push stack (- sp 2) 32 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 32 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 33 goto-table nil)))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 33 goto-table (cons (if $1 (car $1) $2) $2))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 33 goto-table (cons (if $1 (car $1) $2) $2))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 33 goto-table (cons (if $1 (car $1) (car $2)) (cdr $2)))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 34 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 35 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 36 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 37 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 38 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 39 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 40 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 41 goto-table (cons (car $1) (if $2 (cdr $2) (cdr $1))))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 42 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 43 goto-table (cons $1 (if $2 (cdr $2) $1)))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 44 goto-table (cons $1 $3))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 45 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 46 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 47 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($3 (aref stack (- sp 1)))
($2 (aref stack (- sp 3)))
($1 (aref stack (- sp 5))))
(lr-push stack (- sp 6) 48 goto-table (cons $1 $3))))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* ()
(lr-push stack (- sp 0) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
- (lambda (stack sp goto-table)
+ (lambda (stack sp goto-table $lookahead)
(let* (($2 (aref stack (- sp 1)))
($1 (aref stack (- sp 3))))
(lr-push stack (- sp 4) 49 goto-table ())))
;;; TEST
+(defvar rotate-memo nil)
(defmacro rotate-memo (var val)
- `(progn
+ `(when rotate-memo
(unless (boundp ',var) (setq ,var ()))
(setq ,var (cons ,val ,var))
(let ((tmp (last ,var (- (length ,var) 100))))
Otherwise it decodes non-ASCII bit patterns as the
default-mime-charset."
(interactive "*r")
-;; (rotate-memo args-eword-decode-region
-;; (list start end (buffer-substring start end) unfolding must-unfold code-conversion))
+ (rotate-memo args-eword-decode-region
+ (list start end (buffer-substring start end) unfolding must-unfold code-conversion))
(save-excursion
(save-restriction
(narrow-to-region start end)
default-mime-charset.
If SEPARATOR is not nil, it is used as header separator."
(interactive "*")
-;; (rotate-memo args-eword-decode-header (list code-conversion))
+ (rotate-memo args-eword-decode-header (list code-conversion))
(unless code-conversion
- (message "eword-decode-header is called with no code-conversion"))
+ (message "eword-decode-header is called with no code-conversion")
+ (sit-for 2))
(if (and code-conversion
(not (mime-charset-to-coding-system code-conversion)))
(setq code-conversion default-mime-charset))
(save-excursion
(save-restriction
(std11-narrow-to-header separator)
-;; (rotate-memo header-eword-decode-header (buffer-substring (point-min) (point-max)))
+ (rotate-memo args-h-eword-decode-header (buffer-substring (point-min) (point-max)))
(if code-conversion
- (let (beg p end field-name field-body len)
+ (let (beg p end field-name field-body decoded)
(goto-char (point-min))
(while (re-search-forward std11-field-head-regexp nil t)
(setq beg (match-beginning 0)
p (match-end 0)
field-name (buffer-substring beg (1- p))
end (std11-field-end)
- field-body (buffer-substring p end))
+ field-body (buffer-substring p end)
+ decoded (ew-decode-field
+ field-name
+ (ew-lf-crlf-to-crlf field-body)))
+ (unless (equal field-body decoded)
+ (setq decoded (ew-crlf-refold
+ decoded
+ (1+ (string-width field-name))
+ fill-column)))
(delete-region p end)
- (insert (ew-crlf-to-lf
- (ew-decode-field field-name
- (ew-lf-crlf-to-crlf field-body))))
- ))
+ (insert (ew-crlf-to-lf decoded))))
(eword-decode-region (point-min) (point-max) t nil nil)
))))
If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
if there are in decoded encoded-words (generated by bad manner MUA
such as a version of Net$cape)."
-;; (rotate-memo args-eword-decode-and-fold-structured-field
-;; (list string start-column max-column must-unfold))
+ (rotate-memo args-eword-decode-and-fold-structured-field
+ (list string start-column max-column must-unfold))
(or max-column
(setq max-column fill-column))
- (let* ((ew-decode-field-default-syntax '(ew-scan-unibyte-std11))
- (decoded (ew-decode-field (make-string (1- start-column) ?X)
- (ew-lf-crlf-to-crlf string)
- (if must-unfold 'ew-cut-cr-lf)))
- column)
- (setq decoded (ew-crlf-to-lf decoded))
- (setq column 0)
- (ew-lf-line-convert decoded
- (lambda (line)
- (if (<= (length line) max-column)
- line
- (let ((start 0) index)
- (catch 'loop
- (while (< (+ column start) max-column)
- (if (string-match " " decoded start)
- (progn
- (setq start (match-end 0))
- (when (< (match-beginning 0) max-column)
- (setq index (match-beginning 0))))
- (throw 'loop nil)))
- (setq index (string-match " " decoded start)))
- (if index
- (concat (substring decoded 0 index)
- "\n"
- (substring decoded index))
- decoded))))
- (lambda (str) (setq column 1) str)
- (lambda (str) (setq column 0) str))))
+ (let* ((field-name (make-string (1- start-column) ?X))
+ (field-body (ew-lf-crlf-to-crlf string))
+ (ew-decode-field-default-syntax '(ew-scan-unibyte-std11))
+ (decoded (ew-decode-field field-name field-body
+ (if must-unfold 'ew-cut-cr-lf))))
+ (unless (equal field-body decoded)
+ (setq decoded (ew-crlf-refold decoded start-column max-column)))
+ (ew-crlf-to-lf decoded)))
(defun eword-decode-and-unfold-structured-field (string)
"Decode and unfold STRING as structured field body.
If an encoded-word is broken or your emacs implementation can not
decode the charset included in it, it is not decoded."
-;; (rotate-memo args-eword-decode-and-unfold-structured-field (list string))
+ (rotate-memo args-eword-decode-and-unfold-structured-field (list string))
(let* ((ew-decode-field-default-syntax '(ew-scan-unibyte-std11))
(decoded (ew-decode-field ""
(ew-lf-crlf-to-crlf string)
If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
if there are in decoded encoded-words (generated by bad manner MUA
such as a version of Net$cape)."
-;; (rotate-memo args-eword-decode-structured-field-body
-;; (list string must-unfold start-column max-column))
+ (rotate-memo args-eword-decode-structured-field-body
+ (list string must-unfold start-column max-column))
(if start-column
;; fold with max-column (folding is not implemented.)
(let* ((ew-decode-field-default-syntax '(ew-scan-unibyte-std11))
If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
if there are in decoded encoded-words (generated by bad manner MUA
such as a version of Net$cape)."
-;; (rotate-memo args-eword-decode-unstructured-field-body
-;; (list string must-unfold))
+ (rotate-memo args-eword-decode-unstructured-field-body
+ (list string must-unfold))
(let ((decoded (ew-decode-field ""
(ew-lf-crlf-to-crlf string)
(if must-unfold 'ew-cut-cr-lf))))
It decodes non us-ascii characters in FULL-NAME encoded as
encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii
characters are regarded as variable `default-mime-charset'."
-;; (rotate-memo args-eword-extract-address-components (list string))
+ (rotate-memo args-eword-extract-address-components (list string))
(let* ((structure (car (std11-parse-address
(eword-lexical-analyze
(std11-unfold-string string) 'must-unfold))))