comparison src/compiler.sml @ 2226:e10881cd92da

Merge.
author Ziv Scully <ziv@mit.edu>
date Fri, 27 Mar 2015 11:26:06 -0400
parents 365727ff68f4 c15f35e507b5
children 2b1af5dc6dee
comparison
equal deleted inserted replaced
2225:6262dabc08d6 2226:e10881cd92da
459 institutionalizeJob job; 459 institutionalizeJob job;
460 {Job = job, Libs = []} 460 {Job = job, Libs = []}
461 end 461 end
462 else 462 else
463 let 463 let
464 val thisPath = OS.Path.dir fname
465
466 val pathmap = ref (!pathmap) 464 val pathmap = ref (!pathmap)
467 val bigLibs = ref [] 465 val bigLibs = ref []
468 466
469 fun pu filename = 467 fun pu filename =
470 let 468 let
471 val filename = OS.Path.mkAbsolute {path = filename, relativeTo = OS.FileSys.getDir ()} 469 val filename = OS.Path.mkAbsolute {path = filename, relativeTo = OS.FileSys.getDir ()}
470 val thisPath = OS.Path.dir filename
472 471
473 val dir = OS.Path.dir filename 472 val dir = OS.Path.dir filename
474 fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"}) 473 fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
475 474
476 val inf = opener () 475 val inf = opener ()
691 | "cookie" => Settings.Cookie 690 | "cookie" => Settings.Cookie
692 | "style" => Settings.Style 691 | "style" => Settings.Style
693 | _ => (ErrorMsg.error "Bad path kind spec"; 692 | _ => (ErrorMsg.error "Bad path kind spec";
694 Settings.Any) 693 Settings.Any)
695 694
696 fun parseFrom s = 695 fun parsePattern s =
697 if size s > 1 andalso String.sub (s, size s - 2) = #"/" andalso String.sub (s, size s - 1) = #"*" then 696 if size s > 0 andalso String.sub (s, size s - 1) = #"*" then
698 (Settings.Prefix, String.substring (s, 0, size s - 1)) 697 (Settings.Prefix, String.substring (s, 0, size s - 1))
699 else 698 else
700 (Settings.Exact, s) 699 (Settings.Exact, s)
701 700
702 fun parseFkind s = 701 fun parseFkind s =
706 | "requestHeader" => request 705 | "requestHeader" => request
707 | "responseHeader" => response 706 | "responseHeader" => response
708 | "env" => env 707 | "env" => env
709 | _ => (ErrorMsg.error "Bad filter kind"; 708 | _ => (ErrorMsg.error "Bad filter kind";
710 url) 709 url)
711
712 fun parsePattern s =
713 if size s > 0 andalso String.sub (s, size s - 1) = #"*" then
714 (Settings.Prefix, String.substring (s, 0, size s - 1))
715 else
716 (Settings.Exact, s)
717 710
718 fun read () = 711 fun read () =
719 case inputCommentableLine inf of 712 case inputCommentableLine inf of
720 EndOfFile => finish [] 713 EndOfFile => finish []
721 | OnlyComment => read () 714 | OnlyComment => read ()
799 | "rewrite" => 792 | "rewrite" =>
800 let 793 let
801 fun doit (pkind, from, to, hyph) = 794 fun doit (pkind, from, to, hyph) =
802 let 795 let
803 val pkind = parsePkind pkind 796 val pkind = parsePkind pkind
804 val (kind, from) = parseFrom from 797 val (kind, from) = parsePattern from
805 in 798 in
806 rewrites := {pkind = pkind, kind = kind, from = from, to = to, hyphenate = hyph} :: !rewrites 799 rewrites := {pkind = pkind, kind = kind, from = from, to = to, hyphenate = hyph} :: !rewrites
807 end 800 end
808 in 801 in
809 case String.tokens Char.isSpace arg of 802 case String.tokens Char.isSpace arg of