#line 254 "/home/travis/build/felix-lang/felix/src/packages/flx_doc.fdoc"
  var ishtml = System::argv 1 == "--html";
  var dir =  Filename::join ("src", "lib", "std");
  var fregex = ".*\\.(flx|fdoc)";
  var lregex = "^ *(virtual|noinline)* *(proc|fun|class|ctor|gen) *(([A-Z]|[a-z])([A-Z]|[a-z]|[0-9]|-|_)*).*";
  var lgrep = RE2 lregex;
  var n = NumberOfCapturingGroups(lgrep)+1;
  var v = varray[StringPiece] (n.size,StringPiece "");
  
  var grexp = RE2 lregex;
  var extract = RE2 " *([^={]*) *(=|{|;).*";
  var n2 = NumberOfCapturingGroups(extract)+1;
  var v2 = varray[StringPiece] (n2.size,StringPiece "");
  var v2a = varray[StringPiece] (n2.size,StringPiece "");
  
  typedef data_t = (file:string, line:int, dfn:string);
  instance Str[data_t] {
    fun str (d:data_t) => d.file + "<"+d.line.str+">:"+d.dfn;
  }
  
  var index = #strdict[list[data_t]];
  
  for file in FileSystem::regfilesin (dir, fregex) do
    //println$ file;
    var text = load (Filename::join dir file);
    var count = 0;
    var lines = split (text, char "\n");
    for line in lines do
      ++count;
      if line != "" do
        var m = Match (grexp, StringPiece line, 0, ANCHOR_BOTH, v.stl_begin,n);
        if m do
          var sym = v.3.string;
          var dfn = "";
          var m2 = Match (extract, StringPiece line, 0, ANCHOR_BOTH, v2.stl_begin, n2);
          if m2 do
            m2 = Match (extract, StringPiece line, 0, ANCHOR_BOTH, v2a.stl_begin, n2);
            if m2 do
              dfn = v2a . 1 . string . strip;
            else
              dfn = v2 . 1 . string . strip;
            done
          else
            dfn = line . strip;
          done
          //println$ file, count, sym,dfn;
          var data = (file=file, line=count, dfn=dfn);
          //val old_data =index.get_dflt(sym,Empty[data_t]);
          //val new_data = Cons (data, old_data);
          //val new_data =Cons (data,index.get_dflt(sym,Empty[data_t]));
          //index.add sym new_data;
          index.add sym (var Cons (data,index.get_dflt(sym,Empty[data_t])));
        done
      done
    done
  done
  
  //println$ "------------------";
  if ishtml do
    var ctrl = char " ";
    println$ "<html><body>";
    println$ "<h1>Felix library Index</h1>";
    println$ "<pre>";
    match key,value in index do
      var newctrl = char key;
      if ctrl != newctrl do
        println$ "<hr/>";
        ctrl = newctrl;
      done
      println$ key;
      match  (file=xfile,line=xline,dfn=xdfn) in value do
       var href = "/share/lib/std/" + xfile;
       println$ '  <a href="'+href+ "#"+f"%04d" xline + '">' + xfile + ":"+ str xline + "</a>: " + xdfn;
      done
    done
    println$ "</pre></body></html>";
  else
    match key,value in index do
      println$ key;
      match  (file=xfile,line=xline,dfn=xdfn) in value do
       println$ "  " + xfile + ":"+ str xline + ": " + xdfn;
      done
    done
  done