Commit 543c06c9 authored by Pietro Abate's avatar Pietro Abate

[r2003-08-15 10:35:24 by cvscast] Improve error message in sequences

Original author: cvscast
Date: 2003-08-15 10:35:25+00:00
parent 1ae0fb6f
since 0.1.0
0.1.1
* Various bug fixes
* Sequencing operator e1;e2 (equivalent to: let [] = e1 in e2)
* Encoded references
......
......@@ -362,10 +362,10 @@ let [x] = bold [doc] in print_xml x;;
let stack = ref [Int*] []
let fun push(x : Int) : [] =
stack := [x ; !stack]
stack := [x; !stack]
let fun pop ([] : []) : Int =
match !stack with [x ; y] -> stack := y; x | _ -> raise \"Empty stack\"
match !stack with [x; y] -> stack := y; x | _ -> raise \"Empty stack\"
(* In a pattern [ ... ; y] the variable y captures the tail *)
......@@ -373,6 +373,7 @@ let fun pop ([] : []) : Int =
(* In an expression [ ... ; e ] the expression e denotes the *)
(* tail of the sequence. It is equivalent to [ ... ] @ e *)
;;
push 1;;
......
......@@ -263,8 +263,10 @@ EXTEND
[ c = const -> exp loc (Cst c)
| "("; l = LIST1 expr SEP ","; ")" -> exp loc (tuple l)
| "["; l = LIST0 seq_elem; e = OPT [ ";"; e = expr -> e ];
(_,loc_end) = ["]" -> loc] ->
loc_end = ["]" -> loc] ->
let e = match e with Some e -> e | None -> cst_nil in
let e = exp loc_end e in
let (_,loc_end) = loc_end in
let l = List.fold_right
(fun x q ->
match x with
......
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