[MLton-commit] r7006

Vesa Karvonen vesak at mlton.org
Sat Dec 20 08:56:40 PST 2008


Whitespace cleanup.

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

U   mlton/trunk/basis-library/text/char.sml

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

Modified: mlton/trunk/basis-library/text/char.sml
===================================================================
--- mlton/trunk/basis-library/text/char.sml	2008-12-20 16:39:32 UTC (rev 7005)
+++ mlton/trunk/basis-library/text/char.sml	2008-12-20 16:56:40 UTC (rev 7006)
@@ -15,34 +15,34 @@
       sharing type PreChar.string = CharVector.vector = CharArray.vector
    end
 
-functor CharFn(Arg : CHAR_ARG) 
-        :> CHAR_EXTRA 
-            where type char   = Arg.PreChar.char 
+functor CharFn(Arg : CHAR_ARG)
+        :> CHAR_EXTRA
+            where type char   = Arg.PreChar.char
             where type string = Arg.PreChar.string =
    struct
       open Arg.PreChar
-      
+
       type string = Arg.CharVector.vector
       val maxOrd: int = numChars - 1
-      
-      val fromString = Arg.CharVector.fromPoly o 
+
+      val fromString = Arg.CharVector.fromPoly o
                        Vector.map (fn x => fromChar x) o
                        String.toPoly
 
       fun succ c =
-         if Primitive.Controls.safe 
+         if Primitive.Controls.safe
             andalso c = maxChar
             then raise Chr
          else chrUnsafe (Int.+ (ord c, 1))
 
       fun pred c =
-         if Primitive.Controls.safe 
+         if Primitive.Controls.safe
             andalso c = minChar
             then raise Chr
          else chrUnsafe (Int.- (ord c, 1))
 
       fun chrOpt c =
-         if Primitive.Controls.safe 
+         if Primitive.Controls.safe
             andalso Int.gtu (c, maxOrd)
             then NONE
          else SOME (chrUnsafe c)
@@ -51,14 +51,14 @@
          case chrOpt c of
             NONE => raise Chr
           | SOME c => c
-      
+
       (* To implement character classes, we cannot use lookup tables on the
        * order of the number of characters. We don't want to scan the string
        * each time, so instead we'll sort it and use binary search.
        *)
       fun contains s =
          let
-            val a = Array.tabulate (Arg.CharVector.length s, 
+            val a = Array.tabulate (Arg.CharVector.length s,
                                     fn i => Arg.CharVector.sub (s, i))
             val () = Heap.heapSort (a, op <)
          in
@@ -70,13 +70,13 @@
                   Array.sub (a, x) = c
                end
          end
-      
+
       fun notContains s = not o contains s
-      
+
       val c = fromChar
       val (  la,    lA,    lf,    lF,    lz,    lZ,    l0,    l9,  lSPACE,lBANG, lTIL,  lDEL) =
           (c#"a", c#"A", c#"f", c#"F", c#"z", c#"Z", c#"0", c#"9", c#" ", c#"!", c#"~", c#"\127")
-      
+
       (* Range comparisons don't need tables! It's faster to just compare. *)
       fun isLower c = c >= la andalso c <= lz
       fun isUpper c = c >= lA andalso c <= lZ
@@ -85,7 +85,7 @@
       fun isPrint c = c >= lSPACE andalso c <= lTIL
       fun isCntrl c = c <  lSPACE orelse  c  = lDEL
       fun isAscii c = c <= lDEL
-      
+
       local
          (* We can use a table for small ranges *)
          val limit = 128
@@ -94,22 +94,22 @@
                val v = Vector.tabulate (limit, f o chrUnsafe)
                val limit = chr limit
             in
-               fn c => if c >= limit then g c else 
+               fn c => if c >= limit then g c else
                        Vector.sub (v, ord c)
             end
-         
+
          fun make (test, diff) =
-            memoize (fn c => if test c then chrUnsafe (Int.+? (ord c, diff)) 
+            memoize (fn c => if test c then chrUnsafe (Int.+? (ord c, diff))
                                        else c,
                      fn c => c)
          val diff = Int.- (ord lA, ord la)
-      
+
          infix || &&
          fun f || g = memoize (fn c => f c orelse  g c, fn _ => false)
          fun f && g = memoize (fn c => f c andalso g c, fn _ => false)
-         
+
          val WS = fromString " \t\r\n\v\f"
-         
+
          fun laf c = (c >= la andalso c <= lf) orelse
                      (c >= lA andalso c <= lF)
       in
@@ -118,11 +118,11 @@
          val isAlphaNum = isAlpha || isDigit
          val isSpace = memoize (contains WS, fn _ => false)
          val isPunct = isGraph && (not o isAlphaNum)
-         
+
          val toLower = make (isUpper, Int.~ diff)
          val toUpper = make (isLower, diff)
       end
-      
+
       fun control reader state =
          case reader state of
             NONE => NONE
@@ -226,9 +226,9 @@
          in
             main
          end
-      
+
       val fromString = StringCvt.scanString scan
-      
+
       fun 'a scanC (reader: (Char.char, 'a) StringCvt.reader)
         : (char, 'a) StringCvt.reader =
          let
@@ -294,14 +294,14 @@
                     then s
                  else raise Fail "padLeft"
          end
-      
+
       fun unicodeEscape ord =
           if Int.< (ord, 65536)
              then String.concat
                   ["\\u", padLeft (Int.fmt StringCvt.HEX ord, 4)]
           else String.concat
                ["\\U", padLeft (Int.fmt StringCvt.HEX ord, 8)]
-      
+
       fun toString c =
          let
             val ord = ord c
@@ -325,15 +325,15 @@
                 | _ =>
                    if Int.< (ord, 32)
                       then String.concat
-                           ["\\^", String.new 
-                                   (1, Char.chrUnsafe 
+                           ["\\^", String.new
+                                   (1, Char.chrUnsafe
                                        (Int.+? (ord, 64 (* #"@" *) )))]
                    else if Int.< (ord, 256)
                       then String.concat
                            ["\\", padLeft (Int.fmt StringCvt.DEC ord, 3)]
                    else unicodeEscape ord
          end
-      
+
       fun toCString c =
          let
             val ord = ord c
@@ -355,7 +355,7 @@
                 | 11 (* #"\v" *) => "\\v"
                 | 12 (* #"\f" *) => "\\f"
                 | 13 (* #"\r" *) => "\\r"
-                | _ => 
+                | _ =>
                    if Int.< (ord, 256)
                       then String.concat
                            ["\\", padLeft (Int.fmt StringCvt.OCT ord, 3)]




More information about the MLton-commit mailing list