\section{Finding Promela definitions}
<<*>>=
global showlocal
procedure rcsinfo () 
  return "$Id: promeladefs.nw,v 1.17 2008/10/06 01:03:05 nr Exp nr $" ||
         "$Name: v2_12 $"
end
procedure main(args)
  showlocal := !args == "-local"
  go()
end
<<*>>=
procedure postpass(name, arg)
  static kind, mtype
  initial { kind := "bogus" }
  case name of {
    "begin" : arg ? kind := tab(upto(' ')|0)
    "text" : if kind == "code" then arg ?
        if \mtype then
             mtype := write_mtypes()
        else if (optwhite(), =("proctype "|"chan ")) then {
            tab(many(' '))
            writedefn(tab(upto(' ():;')))
        } else if (optwhite(), ="mtype", optwhite(), ="{") then
	    mtype := write_mtypes()
  }
  return
end

procedure write_mtypes()
  static start, alnum
  initial { start := &letters ++ '/,}'; alnum := &letters ++ &digits ++ '_' }
  optwhite()
  while any(start) do {
    if ="/*" then tab(upto("*/") | 0)
    else if ="," then &null
    else if ="}" then return &null
    else if any(alnum) then writedefn(tab(many(alnum)))
    else if pos(0) then return 1
    else if ="/" then return &null
    else { write(&errout, "bad mtype ", tab(0)); return &null }
    optwhite();
  }
  return if pos(0) then 1 else &null
end
    

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

procedure optwhite()
  suspend tab(many(' \t')) | ""
end


