1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374(* Yoann Padioleau
*
* Copyright (C) 2010 Facebook
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License (GPL)
* version 2 as published by the Free Software Foundation.
*
* This program 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.
*)moduleTH=Token_helpers_nw(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*****************************************************************************)(* Types *)(*****************************************************************************)(* the token list contains also the comment-tokens *)typeprogram_and_tokens=Ast_nw.program*Lexer_nw.tokenlist(*****************************************************************************)(* Lexing only *)(*****************************************************************************)lettokens2file=Lexer_nw.reset();lettokenlexbuf=(matchLexer_nw.current_mode()with|Lexer_nw.INITIAL->Lexer_nw.texlexbuf|Lexer_nw.IN_VERBATIMs->Lexer_nw.verbatimslexbuf|Lexer_nw.IN_NOWEB_CHUNK->Lexer_nw.noweblexbuf)inParse_info.tokenize_all_and_adjust_posfiletokenTH.visitor_info_of_tokTH.is_eoflettokensa=Common.profile_code"Parse_nw.tokens"(fun()->tokens2a)(*****************************************************************************)(* Fuzzy parsing *)(*****************************************************************************)letparse_fuzzyfile=lettoks=tokensfileinlettrees=Lib_ast_fuzzy.mk_trees{Lib_ast_fuzzy.tokf=TH.info_of_tok;kind=TH.token_kind_of_tok;}toksintrees,toks(*****************************************************************************)(* Main entry point *)(*****************************************************************************)letparse2filename=letstat=Parse_info.default_statfilenameinlet(ast,toks)=parse_fuzzyfilenamein(ast,toks),statletparsea=Common.profile_code"Parse_nw.parse"(fun()->parse2a)