Mercurial > urweb
comparison src/compiler.sml @ 2096:6b7749da1ddc
Broaden handling of wildcard rewrites
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 24 Dec 2014 12:35:20 -0500 |
parents | 88841212f0ba |
children | c15f35e507b5 |
comparison
equal
deleted
inserted
replaced
2095:d9f918b79b5a | 2096:6b7749da1ddc |
---|---|
691 | "cookie" => Settings.Cookie | 691 | "cookie" => Settings.Cookie |
692 | "style" => Settings.Style | 692 | "style" => Settings.Style |
693 | _ => (ErrorMsg.error "Bad path kind spec"; | 693 | _ => (ErrorMsg.error "Bad path kind spec"; |
694 Settings.Any) | 694 Settings.Any) |
695 | 695 |
696 fun parseFrom s = | 696 fun parsePattern s = |
697 if size s > 1 andalso String.sub (s, size s - 2) = #"/" andalso String.sub (s, size s - 1) = #"*" then | 697 if size s > 0 andalso String.sub (s, size s - 1) = #"*" then |
698 (Settings.Prefix, String.substring (s, 0, size s - 1)) | 698 (Settings.Prefix, String.substring (s, 0, size s - 1)) |
699 else | 699 else |
700 (Settings.Exact, s) | 700 (Settings.Exact, s) |
701 | 701 |
702 fun parseFkind s = | 702 fun parseFkind s = |
706 | "requestHeader" => request | 706 | "requestHeader" => request |
707 | "responseHeader" => response | 707 | "responseHeader" => response |
708 | "env" => env | 708 | "env" => env |
709 | _ => (ErrorMsg.error "Bad filter kind"; | 709 | _ => (ErrorMsg.error "Bad filter kind"; |
710 url) | 710 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 | 711 |
718 fun read () = | 712 fun read () = |
719 case inputCommentableLine inf of | 713 case inputCommentableLine inf of |
720 EndOfFile => finish [] | 714 EndOfFile => finish [] |
721 | OnlyComment => read () | 715 | OnlyComment => read () |
799 | "rewrite" => | 793 | "rewrite" => |
800 let | 794 let |
801 fun doit (pkind, from, to, hyph) = | 795 fun doit (pkind, from, to, hyph) = |
802 let | 796 let |
803 val pkind = parsePkind pkind | 797 val pkind = parsePkind pkind |
804 val (kind, from) = parseFrom from | 798 val (kind, from) = parsePattern from |
805 in | 799 in |
806 rewrites := {pkind = pkind, kind = kind, from = from, to = to, hyphenate = hyph} :: !rewrites | 800 rewrites := {pkind = pkind, kind = kind, from = from, to = to, hyphenate = hyph} :: !rewrites |
807 end | 801 end |
808 in | 802 in |
809 case String.tokens Char.isSpace arg of | 803 case String.tokens Char.isSpace arg of |