[MLton-commit] r5078

Vesa Karvonen vesak at mlton.org
Mon Jan 29 08:03:47 PST 2007


Modified to compute regions for the short identifiers of a long
identifier.

----------------------------------------------------------------------

U   mlton/trunk/mlton/ast/longid.fun
U   mlton/trunk/mlton/control/source-pos.sig
U   mlton/trunk/mlton/control/source-pos.sml

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/ast/longid.fun
===================================================================
--- mlton/trunk/mlton/ast/longid.fun	2007-01-29 14:41:29 UTC (rev 5077)
+++ mlton/trunk/mlton/ast/longid.fun	2007-01-29 16:03:46 UTC (rev 5078)
@@ -90,11 +90,36 @@
 
 fun fromSymbols (ss: Symbol.t list, region: Region.t): t =
    let
-      val (strids, id) = List.splitLast ss
+      val srs =
+         case Region.left region of
+             NONE => List.map (ss, fn s => (s, region))
+           | SOME p =>
+             let
+                val file = SourcePos.file p
+                val line = SourcePos.line p
+             in
+                List.unfold
+                ((ss, SourcePos.column p),
+                 fn (s::ss, cl) =>
+                    let
+                       val cr = cl + String.length (Symbol.toString s)
+                    in
+                       SOME
+                       ((s, Region.make
+                            {left = SourcePos.make {column = cl,
+                                                    file = file,
+                                                    line = line},
+                             right = SourcePos.make {column = cr,
+                                                     file = file,
+                                                     line = line}}),
+                        (ss, cr + 1))
+                    end
+                  | ([], _) => NONE)
+             end
+      val (strids, id) = List.splitLast srs
    in
-      makeRegion (T {strids = List.map (strids, fn s =>
-                                        Strid.fromSymbol (s, region)),
-                     id = Id.fromSymbol (id, region)},
+      makeRegion (T {strids = List.map (strids, Strid.fromSymbol),
+                     id = Id.fromSymbol id},
                   region)
    end
 

Modified: mlton/trunk/mlton/control/source-pos.sig
===================================================================
--- mlton/trunk/mlton/control/source-pos.sig	2007-01-29 14:41:29 UTC (rev 5077)
+++ mlton/trunk/mlton/control/source-pos.sig	2007-01-29 16:03:46 UTC (rev 5078)
@@ -19,6 +19,7 @@
       type t
 
       val bogus: t
+      val column: t -> int
       val compare: t * t -> Relation.t
       val equals: t * t -> bool
       val file: t -> File.t

Modified: mlton/trunk/mlton/control/source-pos.sml
===================================================================
--- mlton/trunk/mlton/control/source-pos.sml	2007-01-29 14:41:29 UTC (rev 5077)
+++ mlton/trunk/mlton/control/source-pos.sml	2007-01-29 16:03:46 UTC (rev 5078)
@@ -16,6 +16,7 @@
 local
    fun f g (T r) = g r
 in
+   val column = f #column
    val line = f #line
 end
 




More information about the MLton-commit mailing list