summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2009-01-15 22:22:53 +0100
committerGuillaume Seguin <guillaume@segu.in>2009-01-15 22:22:53 +0100
commitd044a93f39682268ffca60159bd1a0706d2d6050 (patch)
tree8a3d838b6c5584b9478533c9a38ba416d5d43cad
parentee85f525da54e20afe0dc7dd5583c53545dcad81 (diff)
downloadpetitcaml-d044a93f39682268ffca60159bd1a0706d2d6050.tar.gz
petitcaml-d044a93f39682268ffca60159bd1a0706d2d6050.tar.bz2
[petitcaml] Fix even more error localisation problems
-rw-r--r--main.ml4
-rw-r--r--parser.mly5
-rw-r--r--utils.ml7
3 files changed, 12 insertions, 4 deletions
diff --git a/main.ml b/main.ml
index 14b1197..84b1f33 100644
--- a/main.ml
+++ b/main.ml
@@ -43,7 +43,7 @@ let localisation_expr = function
eprintf "File \"%s\", line 0, characters 0-%d:\n"
!ifile
!ifile_length
- | Some loc when loc.spos.l = loc.spos.l ->
+ | Some loc when loc.spos.l = loc.epos.l ->
eprintf "File \"%s\", line %d, characters %d-%d:\n"
!ifile
loc.spos.l
@@ -54,7 +54,7 @@ let localisation_expr = function
!ifile
loc.spos.l
loc.spos.c
- (loc.spos.c + loc.epos.raw_c - loc.epos.raw_c)
+ (loc.spos.c + loc.epos.raw_c - loc.spos.raw_c)
(* Le main du compilateur :
* Vérification des arguments, du nom du fichier source
diff --git a/parser.mly b/parser.mly
index e6467ec..7f13b40 100644
--- a/parser.mly
+++ b/parser.mly
@@ -95,8 +95,9 @@ expr:
{ e = (Ecall (base, arg)) ;
t = None ;
loc = arg.loc })
- (locd_expr (Ecall (func, arg))
- (make_loc $startpos $endpos))
+ ({ e = (Ecall (func, arg)) ;
+ t = None ;
+ loc = (make_start_end_loc func.loc arg.loc) })
args }
| FUNCTION m = motif RIGHTARROW e = expr
{ locd_expr (Efunc ({ name = None ;
diff --git a/utils.ml b/utils.ml
index 26f882b..3808f53 100644
--- a/utils.ml
+++ b/utils.ml
@@ -156,6 +156,13 @@ let make_loc startpos endpos =
{ spos = make_pos startpos ;
epos = make_pos endpos }
+let make_start_end_loc sloc eloc =
+ match sloc, eloc with
+ | None, _ -> None
+ | _, None -> None
+ | (Some sloc), (Some eloc) ->
+ Some { spos = sloc.spos ; epos = eloc.epos }
+
(* Création d'un record expr/motif localisé *)
let locd_expr e loc =
{ e = e ; loc = Some loc ; t = None }