Reading Gauche にて

ページ自動生成なスクリプト使ってみては??と助言を受ける。で、そのスクリプト、CPAN なソレ (WWW::Machanize と URI::Escape) に依存しているとの事。perl のモジュール手動で入れれば良いのでしょうが、でびあんパケジが使いたいのぅ、と。そんなコト言ってるクセにパケジの探し方が分からん。おそらくは

liburi-perl libwww-perl

あたり、と勝手に目星を付けて入れてみる。

# apt-get install -fy liburi-perl libwww-perl -s
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl
Suggested packages:
  libio-socket-ssl-perl
Recommended packages:
  libmailtools-perl libhtml-format-perl libcompress-zlib-perl
The following NEW packages will be installed:
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl liburi-perl libwww-perl
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Inst libhtml-tagset-perl (3.10-2 Debian:4.0r3/stable)
Inst liburi-perl (1.35-2 Debian:4.0r3/stable)
Inst libhtml-parser-perl (3.55-1 Debian:4.0r3/stable)
Inst libhtml-tree-perl (3.19.01-2 Debian:4.0r3/stable)
Inst libwww-perl (5.805-1 Debian:4.0r3/stable)
Conf libhtml-tagset-perl (3.10-2 Debian:4.0r3/stable)
Conf liburi-perl (1.35-2 Debian:4.0r3/stable)
Conf libhtml-parser-perl (3.55-1 Debian:4.0r3/stable)
Conf libhtml-tree-perl (3.19.01-2 Debian:4.0r3/stable)
Conf libwww-perl (5.805-1 Debian:4.0r3/stable)
#

このあたり、インストールする前にチェックする方法って微妙だなぁ。あと libwww-mechanize-perl も入れた。一応 /usr/share/perl5 の中にそれっぽいナニがあるのを確認。多分大丈夫でしょう。

(略
/usr/share/perl5/URI/Escape.pm
(略
/usr/share/perl5/WWW/Mechanize.pm
(略

確認は別途。とりあえず今からヒルネ。

最終日対応、現在端末のリカバリ中にて投稿試験をしてみる事に。コマンド的には以下か。

$ perl post_code_reading.pl port.c Scm_GetOutputStringUnsafe \
> gauche/port.h SCM_PORT_TYPE gauche/port.h SCM_PORT \
> gauche.h ScmObj string.c Scm_DStringGet gauche/port.h SCM_PORT_OSTR \
> gauche.h ScmPort error.c Scm_Error
$

できてる模様。なんかイキオイついてしまって、どんどんヤッてしまいそう。ヤバい。

続々

one liner になりそげだったので

*** post_gauche_reading.scm.ORG 2008-03-21 16:03:54.000000000 +0900
--- post_gauche_reading.scm     2008-03-21 16:08:41.000000000 +0900
***************
*** 30,34 ****
      (let loop ([c (read-char)]
                 [ret '()])
        (if (eof-object? c)
!           (for-each (lambda (s) (print (format "[~a/~a]" (car s) (cdr s)))) (collect-gauche-symbols (list->string (reverse ret))))
            (loop (read-char) (cons c ret))))))
--- 30,34 ----
      (let loop ([c (read-char)]
                 [ret '()])
        (if (eof-object? c)
!           (for-each (lambda (s) (display (format "~a ~a " (cdr s) (car s)))) (collect-gauche-symbols (list->string (reverse ret))))
            (loop (read-char) (cons c ret))))))

でこんなカンジでできんかな

$ perl post_code_reading.pl port.c Scm_GetOutputStringUnsafe `./post_gauche_reading.scm`

とりあえず試験は別途になるか、すぐデキるかは不明。

追記

投入 NG。以下でできた。

*** post_gauche_reading.scm.ORG 2008-03-21 16:03:54.000000000 +0900
--- post_gauche_reading.scm     2008-03-21 21:14:04.000000000 +0900
***************
*** 24,34 ****
    (filter-map (lambda (symbol) (assoc symbol gauche-symbols))
            (parse-code code)))
  
! (print "paste your Gauche code and then Ctrl-d")
  (with-input-from-port (standard-input-port)
    (lambda ()
      (let loop ([c (read-char)]
                 [ret '()])
        (if (eof-object? c)
!           (for-each (lambda (s) (print (format "[~a/~a]" (car s) (cdr s)))) (collect-gauche-symbols (list->string (reverse ret))))
            (loop (read-char) (cons c ret))))))
--- 24,34 ----
    (filter-map (lambda (symbol) (assoc symbol gauche-symbols))
            (parse-code code)))
  
! ;;(print "paste your Gauche code and then Ctrl-d")
  (with-input-from-port (standard-input-port)
    (lambda ()
      (let loop ([c (read-char)]
                 [ret '()])
        (if (eof-object? c)
!           (for-each (lambda (s) (display (format "~a ~a " (cdr s) (car s)))) (collect-gauche-symbols (list->string (reverse ret))))
            (loop (read-char) (cons c ret))))))

patch が上手くアタるかは確認してません。(何