Skip to content

Commit 71fa9e9

Browse files
committed
Merge pull request #21120 from fhahn/issue-model-lexer-questionmark
[r+] Issue model lexer questionmark Reviewed-by: alexcrichton
2 parents f9f6e47 + 6cfbcca commit 71fa9e9

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/grammar/RustLexer.g4

+5
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,13 @@ LIT_STR_RAW
194194
: 'r' LIT_STR_RAW_INNER SUFFIX?
195195
;
196196

197+
198+
QUESTION : '?';
199+
197200
IDENT : XID_start XID_continue* ;
198201

202+
fragment QUESTION_IDENTIFIER : QUESTION? IDENT;
203+
199204
LIFETIME : '\'' IDENT ;
200205

201206
WHITESPACE : [ \r\n\t]+ ;

src/grammar/verify.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(globs, plugin)]
11+
#![feature(plugin)]
1212

1313
extern crate syntax;
1414
extern crate rustc;
@@ -107,13 +107,14 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
107107
"LE" => token::Le,
108108
"LIT_BINARY" => token::Literal(token::Binary(Name(0)), None),
109109
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0), None),
110+
"QUESTION" => token::Question,
110111
_ => continue,
111112
};
112113

113114
res.insert(num.to_string(), tok);
114115
}
115116

116-
debug!("Token map: {}", res);
117+
debug!("Token map: {:?}", res);
117118
res
118119
}
119120

@@ -161,7 +162,7 @@ fn fixchar(mut lit: &str) -> ast::Name {
161162
parse::token::intern(lit.slice(1, lit.len() - 1))
162163
}
163164

164-
fn count(lit: &str) -> uint {
165+
fn count(lit: &str) -> usize {
165166
lit.chars().take_while(|c| *c == '#').count()
166167
}
167168

@@ -176,12 +177,12 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
176177
let toknum = m.name("toknum").unwrap_or("");
177178
let content = m.name("content").unwrap_or("");
178179

179-
let proto_tok = tokens.get(toknum).expect(format!("didn't find token {} in the map",
180+
let proto_tok = tokens.get(toknum).expect(format!("didn't find token {:?} in the map",
180181
toknum).as_slice());
181182

182183
let nm = parse::token::intern(content);
183184

184-
debug!("What we got: content (`{}`), proto: {}", content, proto_tok);
185+
debug!("What we got: content (`{}`), proto: {:?}", content, proto_tok);
185186

186187
let real_tok = match *proto_tok {
187188
token::BinOp(..) => token::BinOp(str_to_binop(content)),
@@ -265,7 +266,7 @@ fn main() {
265266
continue
266267
}
267268

268-
assert!(rustc_tok.sp == antlr_tok.sp, "{} and {} have different spans", rustc_tok,
269+
assert!(rustc_tok.sp == antlr_tok.sp, "{:?} and {:?} have different spans", rustc_tok,
269270
antlr_tok);
270271

271272
macro_rules! matches {
@@ -276,12 +277,12 @@ fn main() {
276277
if !tok_cmp(&rustc_tok.tok, &antlr_tok.tok) {
277278
// FIXME #15677: needs more robust escaping in
278279
// antlr
279-
warn!("Different names for {} and {}", rustc_tok, antlr_tok);
280+
warn!("Different names for {:?} and {:?}", rustc_tok, antlr_tok);
280281
}
281282
}
282-
_ => panic!("{} is not {}", antlr_tok, rustc_tok)
283+
_ => panic!("{:?} is not {:?}", antlr_tok, rustc_tok)
283284
},)*
284-
ref c => assert!(c == &antlr_tok.tok, "{} is not {}", rustc_tok, antlr_tok)
285+
ref c => assert!(c == &antlr_tok.tok, "{:?} is not {:?}", rustc_tok, antlr_tok)
285286
}
286287
)
287288
}

0 commit comments

Comments
 (0)