From 4a9dac702cfda30448556f479776412ff870e24e Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 21 Aug 1998 02:22:08 +0000 Subject: [PATCH] * ew-unit.el (ew-eword-p): Use aref instead of substring. (ew-char-decoder): Refined. * lalr-el.scm (gen-larl1): New function. --- ChangeLog | 7 +++++++ ew-unit.el | 26 +++++++++++++------------- lalr-el.scm | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8e9dc6..c61e101 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-08-21 Tanaka Akira + + * ew-unit.el (ew-eword-p): Use aref instead of substring. + (ew-char-decoder): Refined. + + * lalr-el.scm (gen-larl1): New function. + 1998-08-20 Tanaka Akira * ew-var.el (ew-dynamic-options): The result is now integer instead diff --git a/ew-unit.el b/ew-unit.el index f115fab..b658dca 100644 --- a/ew-unit.el +++ b/ew-unit.el @@ -39,8 +39,10 @@ (let ((len (length str))) (and (<= 3 len) - (string= (substring str 0 2) "=?") - (string= (substring str (- len 2) len) "?=")))) + (eq (aref str 0) ?=) + (eq (aref str 1) ??) + (eq (aref str (- len 2)) ??) + (eq (aref str (1- len)) ?=)))) (defun ew-decode-eword (str &optional eword-filter1 eword-filter2) (if (string-match ew-anchored-encoded-word-regexp str) @@ -80,14 +82,12 @@ )) (defun ew-char-decoder (charset) - (catch 'return - (setq charset (downcase charset)) - (let ((sym (intern charset)) - tmp cs) - (when (setq tmp (assq sym ew-charset-aliases)) - (setq sym (cdr tmp))) - (setq cs (intern (concat (symbol-name sym) "-unix"))) - (when (coding-system-p cs) - (throw 'return - (closure-make (lambda (str) (decode-coding-string str cs)) cs))) - nil))) + (let ((sym (intern (downcase charset))) + tmp cs) + (when (setq tmp (assq sym ew-charset-aliases)) + (setq sym (cdr tmp))) + (setq cs (intern (concat (symbol-name sym) "-unix"))) + (when (coding-system-p cs) + (closure-make + (lambda (str) (decode-coding-string str cs)) + cs)))) diff --git a/lalr-el.scm b/lalr-el.scm index 5fe35e1..be9392a 100644 --- a/lalr-el.scm +++ b/lalr-el.scm @@ -308,6 +308,25 @@ (define ngotos #f) (define token-set-size #f) +(define (gen-larl1 gram output-file header footer . opt) + (define (conv-rule-right rr) + (if (null? rr) + '() + (cons (reverse (car rr)) + (cons (cadr rr) + (cons (caddr rr) + (conv-rule-right (cdddr rr))))))) + (apply gen-lalr1 + (map + (lambda (elt) + (if (symbol? elt) + elt + (cons (car elt) (conv-rule-right (cdr elt))))) + gram) + output-file + header + footer + opt)) (define (gen-lalr1 gram output-file header footer . opt) (initialize-all) -- 1.7.10.4