From 504228b1f7b875550eae9e3782a5f2c1033b0233 Mon Sep 17 00:00:00 2001 From: Jacques-Henri Jourdan Date: Wed, 30 Sep 2015 18:41:50 +0200 Subject: Fixed a few bugs in the pre parser. In particular, the following code was not parsed correctly: typedef int a; int f() { for(int a; ;) if(1); a * x; } Additionnaly, I tried to add some comments in the pre-parser code, especially for the different hacks used to solve various conflicts. --- cparser/Parse.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cparser/Parse.ml') diff --git a/cparser/Parse.ml b/cparser/Parse.ml index c9564c08..47698f8d 100644 --- a/cparser/Parse.ml +++ b/cparser/Parse.ml @@ -49,12 +49,16 @@ let preprocessed_file transfs name sourcefile = let p,d = try let t = parse_transformations transfs in - let lb = Lexer.init name ic in let rec inf = Datatypes.S inf in let ast : Cabs.definition list = Obj.magic - (match Timing.time2 "Parsing" - Parser.translation_unit_file inf (Lexer.tokens_stream lb) with + (match Timing.time "Parsing" + (* The call to Lexer.tokens_stream results in the pre + parsing of the entire file. This is non-negligeabe, + so we cannot use Timing.time2 *) + (fun () -> + Parser.translation_unit_file inf (Lexer.tokens_stream name ic)) () + with | Parser.Parser.Inter.Fail_pr -> (* Theoretically impossible : implies inconsistencies between grammars. *) -- cgit