about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2013-08-22 17:00:02 -0400
committerBen Blum <bblum@andrew.cmu.edu>2013-08-23 17:24:14 -0400
commite9f6f3f2ccf563b39f7484025c8272da60c24dfa (patch)
tree42e2f6b59b1972cbfe75ec69d14aa97fbbb478a9 /src/libsyntax/parse/parser.rs
parent2c0f9bd35493def5e23f0f43ddeba54da9d788b4 (diff)
downloadrust-e9f6f3f2ccf563b39f7484025c8272da60c24dfa.tar.gz
rust-e9f6f3f2ccf563b39f7484025c8272da60c24dfa.zip
Parse and reserve typeof keyword. #3228
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 9aa2bf3f063..51213512a55 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -51,7 +51,7 @@ use ast::{struct_variant_kind, subtract};
 use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value};
 use ast::{token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok};
 use ast::{tt_nonterminal, tuple_variant_kind, Ty, ty_, ty_bot, ty_box};
-use ast::{TypeField, ty_fixed_length_vec, ty_closure, ty_bare_fn};
+use ast::{TypeField, ty_fixed_length_vec, ty_closure, ty_bare_fn, ty_typeof};
 use ast::{ty_infer, TypeMethod};
 use ast::{ty_nil, TyParam, TyParamBound, ty_path, ty_ptr, ty_rptr};
 use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, uniq};
@@ -1105,6 +1105,13 @@ impl Parser {
             let result = self.parse_ty_closure(ast::BorrowedSigil, None);
             self.obsolete(*self.last_span, ObsoleteBareFnType);
             result
+        } else if self.eat_keyword(keywords::Typeof) {
+            // TYPEOF
+            // In order to not be ambiguous, the type must be surrounded by parens.
+            self.expect(&token::LPAREN);
+            let e = self.parse_expr();
+            self.expect(&token::RPAREN);
+            ty_typeof(e)
         } else if *self.token == token::MOD_SEP
             || is_ident_or_path(self.token) {
             // NAMED TYPE