From: Yasushi Shoji Date: 2000-04-11T13:09:11+09:00 Subject: [ruby-list:21852] Re: RubyToken::TkSTRING::value やすしです。 From: keiju@Rational.Com (石塚圭樹) Subject: [ruby-list:21827] Re: RubyToken::TkSTRING::value Date: Mon, 10 Apr 2000 13:24:03 +0900 > うーん(^^;;; 必要に応じて機能を拡張するという方針なので, そのままでの再 > 利用は難しいかも(^^;;; え、すごく助かってます(__) [...] > で. 文字列の取り出しですが... 現時点では2通りありまして: > > 1. > irb/ruby-lex.rbの > def identify_string(ltype, quoted = ltype) > > を適当に再定義していただくか, に、してみました。こんな感じですかね? class RubyLex def identify_string(ltype, quoted = ltype) @ltype = ltype @quoted = quoted subtype = nil str = '' begin while ch = getc if @quoted == ch break elsif @ltype != "'" && @ltype != "]" and ch == "#" subtype = true elsif ch == '\\' #' read_escape else str.concat ch end end if @ltype == "/" if peek(0) =~ /i|o|n|e|s/ getc end end if subtype tk = Token(DLtype2Token[ltype], str) else tk = Token(Ltype2Token[ltype], str) end ensure @ltype = nil @quoted = nil @lex_state = EXPR_END end end end で、これだけだと read_escapeにはまると文字が落ちてしまうんですよね‥。 read_escapeは、明日にでも考えてみます。 -- yashi