123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354(* Yoann Padioleau
*
* Copyright (C) 2012 Yoann Padioleau
*
* 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.
*)openCommon(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*
* Just a small wrapper around the C++ parser
*)(*****************************************************************************)(* Types *)(*****************************************************************************)typeprogram_and_tokens=Ast_c.programoption*Parser_cpp.tokenlist(*****************************************************************************)(* Main entry point *)(*****************************************************************************)letparsefile=let(ast2,stat)=Parse_cpp.parse_with_lang~lang:Flag_parsing_cpp.Cfileinletast=ast2|>List.mapfstinlettoks=ast2|>List.mapsnd|>List.flatteninletast_opt,stat=trySome(Ast_c_build.programast),statwithexn->pr2(spf"PB: Ast_c_build, on %s (exn = %s)"file(Common.exn_to_sexn));(*None, { stat with Stat.bad = stat.Stat.bad + stat.Stat.correct } *)raiseexnin(ast_opt,toks),statletparse_programfile=let(program_and_tokens,_stat)=parsefileinCommon2.some(fstprogram_and_tokens)letany_of_stringstr=letany=Parse_cpp.any_of_stringFlag_parsing_cpp.CstrinAst_c_build.anyany