From: Harry Ohlsen Date: 2002-07-05T06:25:07+09:00 Subject: Re: the pains of parsing >... i remember hearing that a language called Snobol had > great string processing capabilities. does anyone know about that? > finally, a Steven J. Hunter sent me this Icon version: > > l_ans := [] > str_in ? until pos(0) do # Written by Steven J. Hunter > if close_delim_cs := \open2close_t[open_delim := move(1)] > then put(l_ans, open_delim||tab(1+bal(close_delim_cs, '<[{','}]>'))) > else tab(many(' ')) | put(l_ans, tab(upto(start_of_nxt_token_cs)|0)) > > a real mouthful, but quite compact. i haven't fully digested this yet. If memory serves correctly, Icon was created by the same person who designed SNOBOL, which probably explains why this code is so succinct. Icon is basically a "better" SNOBOL. I think the guy's name is Griswold, but my memory's not perfect. Mmmm ... "require 'icon'" sounds good to me. Of course, it would probably take as much time to learn how to use the module as it does to become fairly proficient with Ruby as a whole :-).