diff options
author | Jérémie Dimino <jeremie@dimino.org> | 2012-07-20 09:26:12 +0000 |
---|---|---|
committer | Jérémie Dimino <jeremie@dimino.org> | 2012-07-20 09:26:12 +0000 |
commit | a2ad11e98c176e0b63cdd596f54ca05fbe8e95f8 (patch) | |
tree | 89335b2152d7991a3fdb5c9131b27bce79a216e0 | |
parent | cc6726aa6247354d955bc020b240740fa20bd97f (diff) |
PR#5692: fix computation of locations in the camlp4 parser
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12751 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | camlp4/Camlp4/Struct/Grammar/Parser.ml | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/camlp4/Camlp4/Struct/Grammar/Parser.ml b/camlp4/Camlp4/Struct/Grammar/Parser.ml index 2c639b2a1..48054e4df 100644 --- a/camlp4/Camlp4/Struct/Grammar/Parser.ml +++ b/camlp4/Camlp4/Struct/Grammar/Parser.ml @@ -34,16 +34,14 @@ module Make (Structure : Structure.S) = struct 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); |