% -*- mode: Noweb; noweb-code-mode: icon-mode -*-
\section{Finding definitions in $\lambda$-RTL}
<<*>>=
procedure main(args)
  go()
end
<<*>>=
global idchars
procedure postpass(name, arg)
  static kind
  initial { idchars := &letters ++ &digits ++ '_.' 
            kind := "bogus"
          }
  case name of {
    "begin" : arg ? kind := tab(upto(' ')|0)
    "text" : if kind == "code" then (arg || "--") ? (tab(find("--") \ 1) ? {
               if (optwhite(), any(&lcase), t := tab(many(idchars)), optwhite(), ="=")
	       then
                 undotted(t)
               while tab(upto(idchars)) do
                 if (="imports", any(' \t')) then 
                   (tab(upto(idchars)), tab(many(idchars)))
	         else if any(&ucase) then undotted(tab(many(idchars)))
                 else tab(many(idchars))
             })
  }
  return
end

procedure undotted(s)
  return if upto('.', s) then &null else writedefn(s)
end

procedure prepass(name, arg)
  if name == "end" then writedefn(&null) # force newline
end

procedure optwhite()
 suspend tab(many(' \t')) | ""
end
<<*>>=
procedure rcsinfo () 
  return "$Id: asdldefs.nw,v 1.15 2008/10/06 01:03:05 nr Exp nr $" ||
         "$Name: v2_12 $"
end
@