12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091(* Yoann Padioleau
*
* Copyright (C) 2010 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)modulePI=Parse_info(*****************************************************************************)(* Types *)(*****************************************************************************)typetoken=|TCommentof(Ast_lisp.info)|TCommentSpaceof(Ast_lisp.info)|TCommentNewlineof(Ast_lisp.info)|TNumberof(string*Ast_lisp.info)|TIdentof(string*Ast_lisp.info)|TStringof(string*Ast_lisp.info)|TOParenof(Ast_lisp.info)|TCParenof(Ast_lisp.info)|TOBracketof(Ast_lisp.info)|TCBracketof(Ast_lisp.info)|TQuoteof(Ast_lisp.info)(* anti-quote expressions tokens, as in `(foo ,v ,@xs) *)|TBackQuoteof(Ast_lisp.info)|TCommaof(Ast_lisp.info)|TAtof(Ast_lisp.info)|TUnknownof(Ast_lisp.info)|EOFof(Ast_lisp.info)(*****************************************************************************)(* Token Helpers *)(*****************************************************************************)letis_eof=function|EOF_->true|_->falseletis_comment=function|TComment_|TCommentSpace_|TCommentNewline_->true|_->falseletis_just_comment=function|TComment_->true|_->false(*****************************************************************************)(* Visitors *)(*****************************************************************************)letvisitor_info_of_tokf=function|TCommentii->TComment(fii)|TCommentSpaceii->TCommentSpace(fii)|TCommentNewlineii->TCommentNewline(fii)|TNumber(s,ii)->TNumber(s,fii)|TIdent(s,ii)->TIdent(s,fii)|TString(s,ii)->TString(s,fii)|TOParenii->TOParen(fii)|TCParenii->TCParen(fii)|TOBracketii->TOBracket(fii)|TCBracketii->TCBracket(fii)|TQuoteii->TQuote(fii)|TBackQuoteii->TBackQuote(fii)|TCommaii->TComma(fii)|TAtii->TAt(fii)|TUnknownii->TUnknown(fii)|EOFii->EOF(fii)letinfo_of_toktok=letres=refNoneinvisitor_info_of_tok(funii->res:=Someii;ii)tok|>ignore;Common2.some!resletstr_of_tokx=PI.str_of_info(info_of_tokx)