* Simple cross referencer in SNOBOL 4 * &stlimit = 10000 &trim = 1 &anchor = 1 lowers = 'abcdefghijklmnopqrstuvwxyz' uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' letters = lowers uppers wordpat = break(letters) span(letters) . word data('vocab(cnt,refs)') dict = table() * rdline line = input :f(pass2) lincnt = lincnt + 1 rdword line wordpat = :f(rdline) ident(dict<word>) :f(oldword) dict<word> = vocab() refs(dict<word>) = table() oldword cnt(dict<word>) = cnt(dict<word>) + 1 refs(dict<word>)<lincnt> = refs(dict<word>)<lincnt> + 1 :(rdword) * pass2 newdict = sort(convert(dict, 'array')) :f(end) i = 1 nxtword line = newdict<i,1> '[' cnt(newdict<i,2>) ']:' :f(end) oc = convert(refs(newdict<i,2>), 'array') :f(err) j = 0 nxtref j = j + 1 line = line ' ' oc<j,1> :f(out) ident(oc<j,2>, 1) :s(nxtref) line = line '(' oc<j,2> ')' :(nxtref) * out output = line i = i + 1 :(nxtword) * err output = 'Error - program abandaned' end |