Stefan pushed to branch tp/ift6172-2020 at Stefan / Typer
Commits: d17b9efb by Jean-Alexandre Barszcz at 2020-11-23T21:54:14-05:00 * btl/pervasive.typer (quote1): Fix quoting for literals
- - - - -
1 changed file:
- btl/pervasive.typer
Changes:
===================================== btl/pervasive.typer ===================================== @@ -177,8 +177,7 @@ Sexp_cons = cons Sexp; %% which will construct an Sexp equivalent to `x` at run-time. %% This is basically *cross stage persistence* for Sexp. quote1 : Sexp -> Sexp; -quote1 x = let k = K Sexp x; - qlist : List Sexp -> Sexp; +quote1 x = let qlist : List Sexp -> Sexp; qlist xs = case xs | nil => Sexp_symbol "Sexp_nil" | cons x xs @@ -186,6 +185,11 @@ quote1 x = let k = K Sexp x; (cons Sexp (quote1 x) (cons Sexp (qlist xs) (nil Sexp))); + + make_app : String -> Sexp -> Sexp; + make_app str sexp = + Sexp_node (Sexp_symbol str) (cons Sexp sexp (nil Sexp)); + node : Sexp -> List Sexp -> Sexp; node op y = case (Sexp_eq op (Sexp_symbol "uquote")) | true => List_head Sexp Sexp_error y @@ -193,11 +197,26 @@ quote1 x = let k = K Sexp x; (cons Sexp (quote1 op) (cons Sexp (qlist y) (nil Sexp))); - symbol (s : String) = Sexp_node (Sexp_symbol "##Sexp.symbol") - (cons Sexp (Sexp_string s) - (nil Sexp)) + symbol : String -> Sexp; + symbol s = make_app "##Sexp.symbol" (Sexp_string s); + + string : String -> Sexp; + string s = make_app "##Sexp.string" (Sexp_string s); + + integer : Integer -> Sexp; + integer i = make_app "##Sexp.integer" + (make_app "##Int->Integer" (Sexp_integer i)); + + float : Float -> Sexp; + float f = make_app "##Sexp.float" (Sexp_float f); + + block : Sexp -> Sexp; + block sxp = + %% FIXME ##Sexp.block takes a string (and prelexes + %% it) but we have a sexp, what should we do? + Sexp_symbol "<error FIXME block quoting>"; in Sexp_dispatch Sexp x node symbol - (k String) (k Integer) (k Float) (k Sexp); + string integer float block;
%% quote definition quote = macro (lambda x -> (quote1 (List_head Sexp Sexp_error x)));
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/d17b9efb15b360a6748168f0d3c74bee6c...