diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2012-07-30 18:04:46 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2012-07-30 18:04:46 +0000 |
commit | 997a678d5ee774930288bfec23d4b145ce45c078 (patch) | |
tree | ef26b1b6992733f6ee00a1f760ab1da89eaef315 /camlp4/examples | |
parent | b7271628a25d208c90e77dce62ff0244a1c2fcdd (diff) |
clean up TABs and whitespace
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12799 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'camlp4/examples')
-rw-r--r-- | camlp4/examples/arith.ml | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/camlp4/examples/arith.ml b/camlp4/examples/arith.ml index e60c7fb59..15953262c 100644 --- a/camlp4/examples/arith.ml +++ b/camlp4/examples/arith.ml @@ -16,17 +16,17 @@ open Camlp4.PreCast;; module ArithGram = MakeGram(Lexer);; - + type t = Local of string * t * t | Binop of t * (int -> int -> int) * t | Int of int | Var of string;; - + let expression = ArithGram.Entry.mk "expression";; - + EXTEND ArithGram GLOBAL: expression; - + expression: (* A grammar entry for expressions *) [ "top" [ "let"; `LIDENT s; "="; e1 = SELF; "in"; e2 = SELF -> Local(s,e1,e2) ] @@ -41,12 +41,12 @@ | `LIDENT s -> Var(s) | "("; e = expression; ")" -> e ] ]; - + END;; - + let parse_arith s = ArithGram.parse_string expression (Loc.mk "<string>") s;; - + let rec eval env = function | Local(x, e1, e2) -> @@ -56,8 +56,8 @@ op (eval env e1) (eval env e2) | Int(i) -> i | Var(x) -> List.assoc x env;; - + let calc s = Format.printf "%s ==> %d@." s (eval [] (parse_arith s));; - + calc "42 * let x = 21 in x + x";; |