# HG changeset patch # User Adam Chlipala # Date 1419442520 18000 # Node ID 6b7749da1ddc01e07551104d755c751536086b16 # Parent d9f918b79b5a8845a122b837095fa12cfadc89e0 Broaden handling of wildcard rewrites diff -r d9f918b79b5a -r 6b7749da1ddc src/compiler.sml --- a/src/compiler.sml Tue Dec 23 14:41:23 2014 -0500 +++ b/src/compiler.sml Wed Dec 24 12:35:20 2014 -0500 @@ -693,8 +693,8 @@ | _ => (ErrorMsg.error "Bad path kind spec"; Settings.Any) - fun parseFrom s = - if size s > 1 andalso String.sub (s, size s - 2) = #"/" andalso String.sub (s, size s - 1) = #"*" then + fun parsePattern s = + if size s > 0 andalso String.sub (s, size s - 1) = #"*" then (Settings.Prefix, String.substring (s, 0, size s - 1)) else (Settings.Exact, s) @@ -709,12 +709,6 @@ | _ => (ErrorMsg.error "Bad filter kind"; url) - fun parsePattern s = - if size s > 0 andalso String.sub (s, size s - 1) = #"*" then - (Settings.Prefix, String.substring (s, 0, size s - 1)) - else - (Settings.Exact, s) - fun read () = case inputCommentableLine inf of EndOfFile => finish [] @@ -801,7 +795,7 @@ fun doit (pkind, from, to, hyph) = let val pkind = parsePkind pkind - val (kind, from) = parseFrom from + val (kind, from) = parsePattern from in rewrites := {pkind = pkind, kind = kind, from = from, to = to, hyphenate = hyph} :: !rewrites end diff -r d9f918b79b5a -r 6b7749da1ddc src/settings.sml --- a/src/settings.sml Tue Dec 23 14:41:23 2014 -0500 +++ b/src/settings.sml Wed Dec 24 12:35:20 2014 -0500 @@ -378,6 +378,22 @@ datatype path_kind = Any | Url | Table | Sequence | View | Relation | Cookie | Style type rewrite = { pkind : path_kind, kind : pattern_kind, from : string, to : string, hyphenate : bool } +fun pak2s pak = + case pak of + Exact => "Exact" + | Prefix => "Prefix" +fun pk2s pk = + case pk of + Any => "Any" + | Url => "Url" + | Table => "Table" + | Sequence => "Sequence" + | View => "View" + | Relation => "Relation" + | Cookie => "Cookie" + | Style => "Style" +fun r2s (r : rewrite) = pak2s (#kind r) ^ " " ^ pk2s (#pkind r) ^ ", from<" ^ #from r ^ ">, to<" ^ #to r ^ ">" + val rewrites = ref ([] : rewrite list) fun subsume (pk1, pk2) =