# HG changeset patch # User Adam Chlipala # Date 1218326909 14400 # Node ID 5dbba661deab16abdd114c9929d2a972ad573218 # Parent c938fe391c84b3571cafe3e5000a508f50a7ea32 Urlifying records diff -r c938fe391c84 -r 5dbba661deab src/c/lacweb.c --- a/src/c/lacweb.c Sat Aug 09 19:46:12 2008 -0400 +++ b/src/c/lacweb.c Sat Aug 09 20:08:29 2008 -0400 @@ -471,11 +471,11 @@ char *r, *s1, *s2; int len, n; - len = strlen(new_s); + len = strlen(*s); lw_check_heap(ctx, len + 1); r = ctx->heap_front; - ctx->heap_front = lw_unurlifyString_to(ctx, ctx->heap_front, new_s); + ctx->heap_front = lw_unurlifyString_to(ctx, ctx->heap_front, *s); *s = new_s; return r; } diff -r c938fe391c84 -r 5dbba661deab src/cjr_print.sml --- a/src/cjr_print.sml Sat Aug 09 19:46:12 2008 -0400 +++ b/src/cjr_print.sml Sat Aug 09 20:08:29 2008 -0400 @@ -914,7 +914,8 @@ string "+=", space, string (Int.toString (size has_arg)), - string ", ", + string ", (request[0] == '/' ? ++request : NULL), ", + newline, case #1 t of TDatatype _ => unurlify t @@ -990,6 +991,8 @@ string (Int.toString (size x')), string ";", newline, + string "if (request[0] == '/') ++request;", + newline, case to of NONE => box [] | SOME t => box [string "tmp->data.lw_", diff -r c938fe391c84 -r 5dbba661deab src/lacweb.grm --- a/src/lacweb.grm Sat Aug 09 19:46:12 2008 -0400 +++ b/src/lacweb.grm Sat Aug 09 20:08:29 2008 -0400 @@ -89,6 +89,7 @@ | cterm of con | ctuple of con list | ident of con + | idents of con list | rcon of (con * con) list | rconn of (con * con) list | rcone of (con * con) list @@ -324,7 +325,7 @@ ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) | INT (CName (Int64.toString INT), s (INTleft, INTright)) - | path (CVar path, s (pathleft, pathright)) + | SYMBOL (CVar ([], SYMBOL), s (SYMBOLleft, SYMBOLright)) eapps : eterm (eterm) | eapps eterm (EApp (eapps, eterm), s (eappsleft, etermright)) @@ -369,7 +370,13 @@ | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) - | path DOT ident (EField ((EVar path, s (pathleft, pathright)), ident), s (pathleft, identright)) + | path DOT idents (let + val loc = s (pathleft, identsright) + in + foldl (fn (ident, e) => + (EField (e, ident), loc)) + (EVar path, s (pathleft, pathright)) idents + end) | FOLD (EFold, s (FOLDleft, FOLDright)) | XML_BEGIN xml XML_END (xml) @@ -377,6 +384,9 @@ (EPrim (Prim.String ""), s (XML_BEGINleft, XML_ENDright))), s (XML_BEGINleft, XML_ENDright)) +idents : ident ([ident]) + | ident DOT idents (ident :: idents) + etuple : eexp COMMA eexp ([eexp1, eexp2]) | eexp COMMA etuple (eexp :: etuple) diff -r c938fe391c84 -r 5dbba661deab src/monoize.sml --- a/src/monoize.sml Sat Aug 09 19:46:12 2008 -0400 +++ b/src/monoize.sml Sat Aug 09 20:08:29 2008 -0400 @@ -216,7 +216,22 @@ | _ => case t of L'.TFfi (m, x) => ((L'.EFfiApp (m, fk2s fk ^ "ify" ^ capitalize x, [e]), loc), fm) + | L'.TRecord [] => ((L'.EPrim (Prim.String ""), loc), fm) + | L'.TRecord ((x, t) :: xts) => + let + val (se, fm) = fooify fm ((L'.EField (e, x), loc), t) + in + foldl (fn ((x, t), (se, fm)) => + let + val (se', fm) = fooify fm ((L'.EField (e, x), loc), t) + in + ((L'.EStrcat (se, + (L'.EStrcat ((L'.EPrim (Prim.String "/"), loc), + se'), loc)), loc), + fm) + end) (se, fm) xts + end | L'.TDatatype (i, ref (dk, _)) => let diff -r c938fe391c84 -r 5dbba661deab tests/record_page.lac --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/record_page.lac Sat Aug 09 20:08:29 2008 -0400 @@ -0,0 +1,10 @@ +type t = {A : string, B : {C : string, D : string}} + +val page = fn x : t => + {cdata x.A},{cdata x.B.C},{cdata x.B.D} + + +val main : unit -> page = fn () => +
  • First
  • +
  • Second
  • + \ No newline at end of file