comparison src/settings.sml @ 1752:675ce534e3ec

New optional suffice for 'rewrite' in .urp files: [-]
author Adam Chlipala <adam@chlipala.net>
date Sun, 06 May 2012 15:27:30 -0400
parents c414850f206f
children e9587120831a
comparison
equal deleted inserted replaced
1751:acadf9d1214a 1752:675ce534e3ec
324 datatype pattern_kind = Exact | Prefix 324 datatype pattern_kind = Exact | Prefix
325 datatype action = Allow | Deny 325 datatype action = Allow | Deny
326 type rule = { action : action, kind : pattern_kind, pattern : string } 326 type rule = { action : action, kind : pattern_kind, pattern : string }
327 327
328 datatype path_kind = Any | Url | Table | Sequence | View | Relation | Cookie | Style 328 datatype path_kind = Any | Url | Table | Sequence | View | Relation | Cookie | Style
329 type rewrite = { pkind : path_kind, kind : pattern_kind, from : string, to : string } 329 type rewrite = { pkind : path_kind, kind : pattern_kind, from : string, to : string, hyphenate : bool }
330 330
331 val rewrites = ref ([] : rewrite list) 331 val rewrites = ref ([] : rewrite list)
332 332
333 fun subsume (pk1, pk2) = 333 fun subsume (pk1, pk2) =
334 pk1 = pk2 334 pk1 = pk2
355 NONE 355 NONE
356 in 356 in
357 if subsume (pk, #pkind rewr) then 357 if subsume (pk, #pkind rewr) then
358 case match () of 358 case match () of
359 NONE => rew ls 359 NONE => rew ls
360 | SOME suffixStart => #to rewr ^ String.extract (s, suffixStart, NONE) 360 | SOME suffixStart =>
361 let
362 val s = #to rewr ^ String.extract (s, suffixStart, NONE)
363 in
364 if #hyphenate rewr then
365 String.translate (fn #"_" => "-" | ch => str ch) s
366 else
367 s
368 end
361 else 369 else
362 rew ls 370 rew ls
363 end 371 end
364 in 372 in
365 rew (!rewrites) 373 rew (!rewrites)