summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-12-24 12:35:20 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2014-12-24 12:35:20 -0500
commit396975bde3c535e006529a4b24142150ce041f99 (patch)
tree92f1284d28e319a9a70fad17ba197160ee9da0ce /src
parent02a7a466cb332b0d90cf0ec17c6ad9ae7a78ec49 (diff)
Broaden handling of wildcard rewrites
Diffstat (limited to 'src')
-rw-r--r--src/compiler.sml12
-rw-r--r--src/settings.sml16
2 files changed, 19 insertions, 9 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index b46643ff..49b251ba 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -693,8 +693,8 @@ fun parseUrp' accLibs fname =
| _ => (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 @@ fun parseUrp' accLibs fname =
| _ => (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 parseUrp' accLibs fname =
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 --git a/src/settings.sml b/src/settings.sml
index eb350c95..fafb38c5 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -378,6 +378,22 @@ type rule = { action : action, kind : pattern_kind, pattern : string }
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) =