From 7c4129960b0a17fd143e51ba7f6177149b1b74b8 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Fri, 8 Mar 2013 09:34:02 +0000 Subject: [PATCH] Adapt examples. git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13379 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- experimental/frisch/extension_points.txt | 43 ++++++++++-------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/experimental/frisch/extension_points.txt b/experimental/frisch/extension_points.txt index 3b4e8ecf1..5bb8b5154 100644 --- a/experimental/frisch/extension_points.txt +++ b/experimental/frisch/extension_points.txt @@ -364,7 +364,7 @@ with Killed -> bar -- Bolt let funct n = - [%log "funct(%d)" n LEVEL DEBUG]; + (%log "funct(%d)" n LEVEL DEBUG); for i = 1 to n do print_endline "..." done @@ -372,26 +372,20 @@ let funct n = -- pre-polyrecord -let r = ({ x = 1; y = ref None } [@polyrec]) -let () = (r.y <- Some 2) [@polyrec] - -or maybe: - -let r = {[@polyrec] x = 1; y = ref None } -let () = r.y <-[@polyrec] Some 2 - +let r = {%polyrec x = 1; y = ref None } +let () = (%polyrec r.y <- Some 2) -- orakuda -[%regexp function +function%regexp | "$/^[0-9]+$/" as v -> `Int (int_of_string v#_0) | "$/^[a-z][A-Za-z0-9_]*$" as v -> `Variable v#_0 | _ -> failwith "parse error" -] + -- bitstring let bits = Bitstring.bitstring_of_file "/bin/ls" in -[%bit match bits with +match%bitstring bits with | [ 0x7f, 8; "ELF", 24, string; (* ELF magic number *) e_ident, Mul(12,8), bitstring; (* ELF identifier *) e_type, 16, littleendian; (* object file type *) @@ -399,22 +393,19 @@ let bits = Bitstring.bitstring_of_file "/bin/ls" in ] -> printf "This is an ELF binary, type %d, arch %d\n" e_type e_machine -] -- sedlex let rec token buf = - [%sedlex - let Regexp ('a'..'z'|'A'..'Z') = letter in - match buf with - | number -> Printf.printf "Number %s\n" (Sedlexing.Latin1.lexeme buf); token buf - | letter, Star ('A'..'Z' | 'a'..'z' | digit) -> Printf.printf "Ident %s\n" (Sedlexing.Latin1.lexeme buf); token buf - | Plus xml_blank -> token buf - | Plus (Chars "+*-/") -> Printf.printf "Op %s\n" (Sedlexing.Latin1.lexeme buf); token buf - | Range(128,255) -> print_endline "Non ASCII" - | eof -> print_endline "EOF" - | _ -> failwith "Unexpected character" - ] + let%regexp ('a'..'z'|'A'..'Z') = letter in + match%sedlex buf with + | number -> Printf.printf "Number %s\n" (Sedlexing.Latin1.lexeme buf); token buf + | letter, Star ('A'..'Z' | 'a'..'z' | digit) -> Printf.printf "Ident %s\n" (Sedlexing.Latin1.lexeme buf); token buf + | Plus xml_blank -> token buf + | Plus (Chars "+*-/") -> Printf.printf "Op %s\n" (Sedlexing.Latin1.lexeme buf); token buf + | Range(128,255) -> print_endline "Non ASCII" + | eof -> print_endline "EOF" + | _ -> failwith "Unexpected character" -- cppo @@ -431,9 +422,9 @@ debug("test") -- PG'OCaml let fetch_users dbh = - [%pgsql dbh "select id, name from users"] + (%pgsql dbh "select id, name from users") -- Macaque -let names view = [%view {name = t.name}, t <- !view] +let names view = (%view {name = t.name}, t <- !view)