about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-22 17:19:06 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-22 17:51:26 +0200
commitb9b674abe70dd6f666ac3318e26d28c8f61b8e40 (patch)
tree31ab295ff5a3707262e880bb45c03407a342de7e /src/comp/syntax/parse
parentb45d973552c116b90185add4ddb5e4d32bb5cb9b (diff)
downloadrust-b9b674abe70dd6f666ac3318e26d28c8f61b8e40.tar.gz
rust-b9b674abe70dd6f666ac3318e26d28c8f61b8e40.zip
Start adding support for multiple variable declarations per stmt
This adds parser support and most of the machinery for

    auto x = 10, y = 20;

However, the above still goes wrong somewhere in typestate, causing
the state checker to believe only the last variable in the list is
initialized after the statement.

Tim, if you have a moment, could you go over the changes to the tstate
code in this patch and see where I'm going wrong?

Multi-var-decls without the typestate extension

Add a loop
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index a0863319b8d..8ea55673207 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1543,14 +1543,22 @@ fn parse_auto_local(&parser p) -> @ast::local {
 
 fn parse_let(&parser p) -> @ast::decl {
     auto lo = p.get_last_lo_pos();
-    auto local = parse_typed_local(p);
-    ret @spanned(lo, p.get_hi_pos(), ast::decl_local(local));
+    auto locals = ~[parse_typed_local(p)];
+    while p.peek() == token::COMMA {
+        p.bump();
+        locals += ~[parse_typed_local(p)];
+    }
+    ret @spanned(lo, p.get_hi_pos(), ast::decl_local(locals));
 }
 
 fn parse_auto(&parser p) -> @ast::decl {
     auto lo = p.get_last_lo_pos();
-    auto local = parse_auto_local(p);
-    ret @spanned(lo, p.get_hi_pos(), ast::decl_local(local));
+    auto locals = ~[parse_auto_local(p)];
+    while p.peek() == token::COMMA {
+        p.bump();
+        locals += ~[parse_auto_local(p)];
+    }
+    ret @spanned(lo, p.get_hi_pos(), ast::decl_local(locals));
 }
 
 fn parse_stmt(&parser p) -> @ast::stmt {