diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-13 19:59:32 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-13 20:00:03 -0700 |
| commit | 80b6850e34957d95b7606da01d229dc1e3e6e5b5 (patch) | |
| tree | d0b0ddc9c43f8993af890c4a9dff12f91348a8ba /src/libsyntax/parse | |
| parent | 36883186ab88e7b39ea2cb0f47c2c8999840663e (diff) | |
| download | rust-80b6850e34957d95b7606da01d229dc1e3e6e5b5.tar.gz rust-80b6850e34957d95b7606da01d229dc1e3e6e5b5.zip | |
libsyntax: Implement [int*3] syntax for fixed length vector types
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 30f7243d762..bc69edda1a2 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -472,7 +472,19 @@ class parser { ty_rec(elems) } else if self.token == token::LBRACKET { self.expect(token::LBRACKET); - let t = ty_vec(self.parse_mt()); + let mut t = ty_vec(self.parse_mt()); + + // Parse the `* 3` in `[ int * 3 ]` + match self.maybe_parse_fixed_vstore_with_star() { + none => {} + some(suffix) => { + t = ty_fixed_length(@{ + id: self.get_id(), + node: t, + span: mk_sp(lo, self.last_span.hi) + }, suffix) + } + } self.expect(token::RBRACKET); t } else if self.token == token::BINOP(token::AND) { @@ -609,6 +621,22 @@ class parser { } } + fn maybe_parse_fixed_vstore_with_star() -> option<option<uint>> { + if self.eat(token::BINOP(token::STAR)) { + match copy self.token { + token::UNDERSCORE => { + self.bump(); some(none) + } + token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => { + self.bump(); some(some(i as uint)) + } + _ => none + } + } else { + none + } + } + fn lit_from_token(tok: token::token) -> lit_ { match tok { token::LIT_INT(i, it) => lit_int(i, it), |
