aboutsummaryrefslogtreecommitdiff
path: root/src/boot/fe
diff options
context:
space:
mode:
authorOr Brostovski <[email protected]>2010-08-31 06:07:32 +0300
committerGraydon Hoare <[email protected]>2010-09-30 13:45:57 -0700
commit4a3404803b6c6de079a590a4bc96313d9a68f164 (patch)
tree705b0f8710b408c49e3a609bb7ddfc6bdb4a68b3 /src/boot/fe
parentClosed issue 154 - prevents compiler from compiliing a line to zero statements (diff)
downloadrust-4a3404803b6c6de079a590a4bc96313d9a68f164.tar.xz
rust-4a3404803b6c6de079a590a4bc96313d9a68f164.zip
implemented break for while-loop case
ast.ml - added break and cont statements item.ml - added break and cont statements lexer.mll - added break and cont statements token.ml - added break and cont statements trans.ml - implemented the break statement for the while-loop case - replaced hash table accesses with get_stmt_depth where needed type.ml = added break and cont statements typestate.ml - implemented the break statement for the while-loop case - added shorthand filter_live_block_slots walk.ml - added break and cont statements while-with-break.rs - code for testing while loops
Diffstat (limited to 'src/boot/fe')
-rw-r--r--src/boot/fe/ast.ml6
-rw-r--r--src/boot/fe/item.ml9
-rw-r--r--src/boot/fe/lexer.mll2
-rw-r--r--src/boot/fe/token.ml4
4 files changed, 20 insertions, 1 deletions
diff --git a/src/boot/fe/ast.ml b/src/boot/fe/ast.ml
index 54c48f7d..46a87dfe 100644
--- a/src/boot/fe/ast.ml
+++ b/src/boot/fe/ast.ml
@@ -207,6 +207,8 @@ and stmt' =
| STMT_put_each of (lval * (atom array))
| STMT_ret of (atom option)
| STMT_be of (lval * (atom array))
+ | STMT_break
+ | STMT_cont
| STMT_alt_tag of stmt_alt_tag
| STMT_alt_type of stmt_alt_type
| STMT_alt_port of stmt_alt_port
@@ -1228,6 +1230,10 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
fmt_atoms ff az;
fmt ff ";";
+ | STMT_break -> fmt ff "break;";
+
+ | STMT_cont -> fmt ff "cont;";
+
| STMT_block b -> fmt_block ff b.node
| STMT_copy (lv, ex) ->
diff --git a/src/boot/fe/item.ml b/src/boot/fe/item.ml
index 3d3bf84f..c1746cc2 100644
--- a/src/boot/fe/item.ml
+++ b/src/boot/fe/item.ml
@@ -188,7 +188,14 @@ and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
let (stmts, atom) = ctxt "stmts: log value" parse_expr_atom ps in
expect ps SEMI;
spans ps stmts apos (Ast.STMT_log atom)
-
+ | BREAK ->
+ bump ps;
+ expect ps SEMI;
+ [| span ps apos (lexpos ps) Ast.STMT_break |]
+ | CONT ->
+ bump ps;
+ expect ps SEMI;
+ [| span ps apos (lexpos ps) Ast.STMT_cont |]
| CHECK ->
bump ps;
begin
diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll
index 763b50c9..151af827 100644
--- a/src/boot/fe/lexer.mll
+++ b/src/boot/fe/lexer.mll
@@ -113,6 +113,8 @@
("const", CONST);
("log", LOG);
+ ("break", BREAK);
+ ("cont", CONT);
("spawn", SPAWN);
("thread", THREAD);
("yield", YIELD);
diff --git a/src/boot/fe/token.ml b/src/boot/fe/token.ml
index 85dd2a13..cd41ec2f 100644
--- a/src/boot/fe/token.ml
+++ b/src/boot/fe/token.ml
@@ -71,6 +71,8 @@ type token =
| PUT
| RET
| BE
+ | BREAK
+ | CONT
(* Type and type-state keywords *)
| TYPE
@@ -226,6 +228,8 @@ let rec string_of_tok t =
| PUT -> "put"
| RET -> "ret"
| BE -> "be"
+ | BREAK -> "break"
+ | CONT -> "cont"
(* Type and type-state keywords *)
| TYPE -> "type"