#line 1523 "/home/travis/build/felix-lang/felix/src/packages/flx_web.fdoc"
  // Ocaml
  module Ocaml2Html {
  private val big_keywords =
    "module",
    "functor",
    "open",
    "type",
    "class",
    "struct",
    "end",
    "val",
    "inherit",
    "exception"
  ;
  private val small_keywords =
    "if", "then", "else", "elif", "endif", "do", "done",
    "let", "in", "for", "while", "to", "upto","downto",
    "try","match","with","fun","function",
    "begin","end"
  ;
  
  private val qualifiers =
    "virtual", "private"
  ;
  private val hack = "C_hack","C_hack"; // to make it an array we need 2 components
  
  
  fun xlat_ocaml(t:string, dir:string) : bool * string =
  {
    var out = "";
    proc write_string(t:string)
    {
     out += t;
    }
  
    union state_t =
      | sot // start of token
      | id // processing identifier
      | num // in a number
      | dq // processing double quote string
      | ccomment // a C style comment
    ;
    fun str(s:state_t) => match s with
    | #sot => "sot"
    | #id => "id"
    | #num => "num"
    | #dq => "dq"
    | #ccomment => "ccomment"
    endmatch;
  
    var i = 0; var s:state_t;
    var ch = t.[i];
    proc next() { ch = t.[i]; ++i; }
    fun ahead (j:int)=> t.[i + j - 1];
  
    var b = "";
    var last_id = "";
    var last_op = "";
    proc cp() { b += ch; }
    proc ws() {
       write_string('<span class=fstring>'+b+"</span>");
    }
    proc w() {
      //println$ "Token["+str s+"]="+b;
      match s with
      | #dq => ws;
      | #ccomment => write_string('<span class=comment>'+b+"</span>");
      | #id =>
          last_id = b;
          if b in big_keywords do write_string('<span class=big_keyword>'+b+"</span>");
          elif b in small_keywords do write_string('<span class=small_keyword>'+b+"</span>");
          elif b in qualifiers do write_string('<span class=qualifier>'+b+"</span>");
          elif isupper b.[0] do write_string('<span class=ctor>'+b+"</span>");
          else write_string(b); done
      | _ =>
          last_op=b;
          if b == "<" do b = "&lt;";
          elif b == ">" do b = "&gt;";
          elif b == "&" do b = "&amp;";
          done;
          write_string(b);
      endmatch;
      b = "";
    }
  
  
    goto nextt;
  
  contin:> // copy char and continue
    cp();
    goto nextch;
  
  overrun:> // one past last char of token
    w();
    s = sot;
    goto thisch;
  
  lastch:> // last char of token
    cp();
    w();
  
  nextt:>  // new token on next char
    s = sot;
  
  nextch:> // next char
    next();
  
  thisch:> // same char, reconsider it
    //println$ "Considering char " + str(ord(ch));
    if isnull ch goto fin; // out of data
    match s with
    | #sot =>
        if isidstart ch do s = id; goto contin;
        elif isdigit ch do s = num; goto contin;
        elif isdq ch do s = dq; goto contin;
        elif ch == char "(" do
          if ahead(1) == char "*" do cp; next; s = ccomment; goto contin;
          else goto lastch;
          done
        else cp; w; goto nextt;
        done
  
    | #id =>
        if iscamlidcont ch do goto contin;
        else goto overrun;
        done
    | #num =>
        if isnumeric ch do goto contin;
        else goto overrun;
        done
    | #dq =>
        if isdq ch do goto lastch;
        elif ch== char "<" do b+="&lt;"; goto nextch;
        elif ch== char ">" do b+="&gt;"; goto nextch;
        elif ch== char "&" do b+="&amp;"; goto nextch;
        else goto contin;
        done
     // comments
    | #ccomment => // doesn't handle nested comments yet
        if ch == char "*" and ahead(1) == char ")" do
          cp;
          goto lastch;
        else goto contin;
        done
    endmatch
    ;
    println$ "Unexpected drop thru";
  
  fin:>
     println "outof data";
     w(); // whatever is left over gets written
     return false, out;
  }
  }
  
  
  eprintln$ Version::felix_version+"ocaml2html initialisation";
  
  fun setup(x:string) = {
    C_hack::ignore(x); // which means, don't ignore it!
    return 0;
  }
  
  export fun setup of (string) as "ocaml2html_setup";
  export fun Ocaml2Html::xlat_ocaml of (string * string) as "ocaml2html";