aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Parse.ml
diff options
context:
space:
mode:
authorJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-09-30 18:41:50 +0200
committerJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-09-30 18:41:50 +0200
commit504228b1f7b875550eae9e3782a5f2c1033b0233 (patch)
treef3e5121f9694fb57974697475f88361b42da8330 /cparser/Parse.ml
parentc212ab7a8adea516db72f17d818393629dbde1b3 (diff)
downloadcompcert-kvx-504228b1f7b875550eae9e3782a5f2c1033b0233.tar.gz
compcert-kvx-504228b1f7b875550eae9e3782a5f2c1033b0233.zip
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.
Diffstat (limited to 'cparser/Parse.ml')
-rw-r--r--cparser/Parse.ml10
1 files changed, 7 insertions, 3 deletions
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. *)