Commit 6af9c14a authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-11-25 13:54:34 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-25 13:54:35+00:00
parent 7a83b4e7
......@@ -6,7 +6,7 @@ let eval_env = Eval.global_env
let print_norm ppf d =
Location.protect ppf
(fun ppf -> Types.Print.print_descr ppf ((*Types.normalize*) d))
(fun ppf -> Types.Print.print_descr ppf (Types.normalize d))
let print_value ppf v =
Location.protect ppf (fun ppf -> Value.print ppf v)
......
open Location
open Ast
(* let () = Grammar.error_verbose := true *)
let () = Grammar.error_verbose := true
let gram = Grammar.gcreate (Wlexer.lexer Wlexer.token Wlexer.latin1_engine)
......@@ -104,7 +104,17 @@ EXTEND
[ e1 = expr; op = ["+" | "-" | "@"]; e2 = expr -> mk loc (Op (op,[e1;e2]))
]
|
[ e1 = expr; op = ["*" | "/"]; e2 = expr -> mk loc (Op (op,[e1;e2]))
[ e1 = expr; op = ["*"]; e2 = expr -> mk loc (Op (op,[e1;e2]))
| e = expr; op = "/"; p = pat ->
let tag = mk loc (Internal (Types.atom (Atoms.any))) in
let att = mk loc (Internal Types.Record.any) in
let any = mk loc (Internal (Types.any)) in
let re = Star(Alt(SeqCapture("x",Elem p), Elem any)) in
let ct = mk loc (Regexp (re,any)) in
let p = mk loc (XmlT (tag, multi_prod loc [att;ct])) in
let b = (p, mk loc (Var "x")) in
mk loc (Op ("flatten", [mk loc (Map (e,[b]))]))
]
|
[ e = expr; "."; l = [LIDENT | UIDENT] ->
......@@ -123,7 +133,8 @@ EXTEND
e = expr -> mk loc (Op (op,[e]))
| op = [ LIDENT "dump_to_file" ];
e1 = expr LEVEL "no_appl"; e2 = expr -> mk loc (Op (op, [e1;e2]))
| e1 = expr; e2 = expr -> mk loc (Apply (e1,e2))
| e1 = SELF; LIDENT "div"; e2 = expr -> mk loc (Op ("/", [e1;e2]))
| e1 = SELF; e2 = expr -> mk loc (Apply (e1,e2))
]
| "no_appl"
......
......@@ -91,3 +91,6 @@ let bib : Biblio =
do_biblio bib
;;
[bib]/<paper>_/<author>_;;
......@@ -147,7 +147,7 @@ let fun eval ( Expr -> Int )
| (`add,x,y) -> eval x + eval y
| (`mul,x,y) -> eval x * eval y
| (`sub,x,y) -> eval x - eval y
| (`div,x,y) -> eval x / eval y
| (`div,x,y) -> (eval x) div (eval y)
| n -> n
in
eval (`add, 10, (`mul, 20, 5));;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment