<commit_before>structure Go = struct

exception Nope of string 

val () = 
   let 
      fun join (dir, file) = OS.Path.joinDirFile {dir = dir, file = file}

      fun checkfor ds basedir [] = basedir
        | checkfor ds basedir (subdir :: subdirs) = 
          (case OS.FileSys.readDir ds of
              NONE => 
              let val newbasedir = join (basedir, subdir) in
                 OS.FileSys.mkDir newbasedir
                 ; checkfor (OS.FileSys.openDir newbasedir) newbasedir subdirs
              end
            | SOME s => 
              if s <> subdir 
              then checkfor ds basedir (subdir :: subdirs)
              else let val newbasedir = join (basedir, subdir) in
              if OS.FileSys.isDir newbasedir 
              then checkfor (OS.FileSys.openDir newbasedir) newbasedir subdirs
              else raise Nope (newbasedir ^ " exists and is not a directory")
              end)
(*
      val file = 
          case CommandLine.arguments () of 
             [ name ] => 
*)

   in
      (print ("Success!\n"); OS.Process.exit OS.Process.success)
   end handle Nope s => 
      (print ("Error: " ^ s ^ ".\n"); OS.Process.exit OS.Process.success)

end
<commit_msg>Make frontend functional<commit_after>structure Go = struct

exception Nope of string 

val () = 
   let 
      fun join (dir, file) = OS.Path.joinDirFile {dir = dir, file = file}

      fun chk ds basedir [] = basedir
        | chk ds basedir (subdir :: subdirs) = 
          (case OS.FileSys.readDir ds of
              NONE => 
              let val newbasedir = join (basedir, subdir) in
                 OS.FileSys.mkDir newbasedir
                 ; chk (OS.FileSys.openDir newbasedir) newbasedir subdirs
              end
            | SOME s => 
              if s <> subdir 
              then chk ds basedir (subdir :: subdirs)
              else let val newbasedir = join (basedir, subdir) in
              if OS.FileSys.isDir newbasedir 
              then chk (OS.FileSys.openDir newbasedir) newbasedir subdirs
              else raise Nope (newbasedir ^ " exists and is not a directory")
              end)
      val (filein, fileout) = 
          case CommandLine.arguments () of 
             [ name ] => 
             let 
                val here = fn () => OS.FileSys.openDir "."
                val din  = chk (here ()) "." ["examples"]
                val dout = chk (here ()) "." ["src", "l10", "examples"]
             in
                (join (din, name ^ ".l10"), join (dout, name ^ ".x10"))
             end
           | args => 
             (print ("Usage: " ^ CommandLine.name () ^ " <name>\n");
              print ("l10front will read examples/<name>.l10,\n");
              print ("and then it will write src/l10/examples/<name>.x10\n\n");
              raise Nope ("expected 1 argument, found " 
                          ^ Int.toString (length args)))

      val program = Parse.parse filein
   in
      print ("Parsed " ^ Int.toString (length program) ^ " lines(s)\n")
      ; print ("Send output to " ^ fileout ^ "\n")
      ; print ("Success!\n")
      ; OS.Process.exit OS.Process.success
   end handle Nope s => 
      (print ("Error: " ^ s ^ ".\n"); OS.Process.exit OS.Process.success)

end

{'fraction_non_alphanumeric': 0.111557478368356, 'fraction_numerical': 0.0046353522867737945, 'mean_word_length': 1.6, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1584993', 'n_tokens_mistral': 985, 'n_tokens_neox': 929, 'n_words': 290}