Commit 8a37cb49 authored by Pietro Abate's avatar Pietro Abate
Browse files

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