123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566(** Functions managing blanks *)typebuf=Input.buffertypeidx=Input.idx(** A blank function is just a function progressing in a buffer *)typeblank=buf->idx->buf*idxtypet=blank(** Use when you have no blank chars *)letnone:blank=funsn->(s,n)(** Blank from a charset *)letfrom_charset:Charset.t->blank=funcssn->letrecfnsn=let(c,s',n')=Input.readsninifCharset.memcscthenfns'n'else(s,n)infnsn(** Blank from a terminal *)letfrom_terminal:'aLex.t->blank=funtsn->trylet(_,s,n)=t.fsnin(s,n)withLex.NoParse->(s,n)(** blank with c++/lisp/shell like comments *)letline_comments:?cs:Charset.t->string->blank=fun?(cs=Charset.from_string" \t\n\r")start_comment->letstart_comment=(Lex.stringstart_comment).finfunsn->letrecfnsn=let(c,s',n')=Input.readsninifCharset.memcscthenfns'n'elsetrylet(_,s,n)=start_commentsninletrecgnsn=let(c,s',n')=Input.readsninifc<>'\n'&&c<>'\r'thengns'n'elsefnsningnsnwithLex.NoParse->(s,n)infnsn(** Layout records *)typelayout_config={old_blanks_before:bool(** Ignoring blanks with the old blank function before parsing? *);new_blanks_before:bool(** Then ignore blanks with the new blank function (before parsing)? *);new_blanks_after:bool(** Use the new blank function one last time before resuming old layout? *);old_blanks_after:bool(** Use then the old blank function one last time as well? *)}letdefault_layout_config:layout_config={old_blanks_before=true;new_blanks_before=false;new_blanks_after=false;old_blanks_after=true}