Commits

Anonymous committed 6b0c303

PR#5692: fix computation of locations in the camlp4 parser

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12751f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (1)

camlp4/Camlp4/Struct/Grammar/Parser.ml

   value drop_prev_loc = Tools.drop_prev_loc;
 
   value add_loc bp parse_fun strm =
-    let count1 = Stream.count strm in
     let x = parse_fun strm in
-    let count2 = Stream.count strm in
+    let ep = loc_ep strm in
     let loc =
-      if count1 < count2 then
-        let ep = loc_ep strm in
-        Loc.merge bp ep
-      else
+      if Loc.start_off bp > Loc.stop_off ep then
         (* If nothing has been consumed, create a 0-length location. *)
         Loc.join bp
+      else
+        Loc.merge bp ep
     in
     (x, loc);