Skip to content

Commit adda899

Browse files
committed
Update grammer/verify.rs to work with recent master
1 parent 2881953 commit adda899

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

src/grammar/verify.rs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
6161
"SHL" => token::BinOp(token::Shl),
6262
"LBRACE" => token::OpenDelim(token::Brace),
6363
"RARROW" => token::RArrow,
64-
"LIT_STR" => token::Literal(token::Str_(Name(0))),
64+
"LIT_STR" => token::Literal(token::Str_(Name(0)), None),
6565
"DOTDOT" => token::DotDot,
6666
"MOD_SEP" => token::ModSep,
6767
"DOTDOTDOT" => token::DotDotDot,
@@ -71,7 +71,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
7171
"ANDAND" => token::AndAnd,
7272
"AT" => token::At,
7373
"LBRACKET" => token::OpenDelim(token::Bracket),
74-
"LIT_STR_RAW" => token::Literal(token::StrRaw(Name(0), 0)),
74+
"LIT_STR_RAW" => token::Literal(token::StrRaw(Name(0), 0), None),
7575
"RPAREN" => token::CloseDelim(token::Paren),
7676
"SLASH" => token::BinOp(token::Slash),
7777
"COMMA" => token::Comma,
@@ -80,8 +80,8 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
8080
"TILDE" => token::Tilde,
8181
"IDENT" => id(),
8282
"PLUS" => token::BinOp(token::Plus),
83-
"LIT_CHAR" => token::Literal(token::Char(Name(0))),
84-
"LIT_BYTE" => token::Literal(token::Byte(Name(0))),
83+
"LIT_CHAR" => token::Literal(token::Char(Name(0)), None),
84+
"LIT_BYTE" => token::Literal(token::Byte(Name(0)), None),
8585
"EQ" => token::Eq,
8686
"RBRACKET" => token::CloseDelim(token::Bracket),
8787
"COMMENT" => token::Comment,
@@ -95,9 +95,9 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
9595
"BINOP" => token::BinOp(token::Plus),
9696
"POUND" => token::Pound,
9797
"OROR" => token::OrOr,
98-
"LIT_INTEGER" => token::Literal(token::Integer(Name(0))),
98+
"LIT_INTEGER" => token::Literal(token::Integer(Name(0)), None),
9999
"BINOPEQ" => token::BinOpEq(token::Plus),
100-
"LIT_FLOAT" => token::Literal(token::Float(Name(0))),
100+
"LIT_FLOAT" => token::Literal(token::Float(Name(0)), None),
101101
"WHITESPACE" => token::Whitespace,
102102
"UNDERSCORE" => token::Underscore,
103103
"MINUS" => token::BinOp(token::Minus),
@@ -107,8 +107,8 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
107107
"OR" => token::BinOp(token::Or),
108108
"GT" => token::Gt,
109109
"LE" => token::Le,
110-
"LIT_BINARY" => token::Literal(token::Binary(Name(0))),
111-
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0)),
110+
"LIT_BINARY" => token::Literal(token::Binary(Name(0)), None),
111+
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0), None),
112112
_ => continue,
113113
};
114114

@@ -189,17 +189,17 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
189189
token::BinOp(..) => token::BinOp(str_to_binop(content)),
190190
token::BinOpEq(..) => token::BinOpEq(str_to_binop(content.slice_to(
191191
content.len() - 1))),
192-
token::Literal(token::Str_(..)) => token::Literal(token::Str_(fix(content))),
193-
token::Literal(token::StrRaw(..)) => token::Literal(token::StrRaw(fix(content),
194-
count(content))),
195-
token::Literal(token::Char(..)) => token::Literal(token::Char(fixchar(content))),
196-
token::Literal(token::Byte(..)) => token::Literal(token::Byte(fixchar(content))),
192+
token::Literal(token::Str_(..), n) => token::Literal(token::Str_(fix(content)), n),
193+
token::Literal(token::StrRaw(..), n) => token::Literal(token::StrRaw(fix(content),
194+
count(content)), n),
195+
token::Literal(token::Char(..), n) => token::Literal(token::Char(fixchar(content)), n),
196+
token::Literal(token::Byte(..), n) => token::Literal(token::Byte(fixchar(content)), n),
197197
token::DocComment(..) => token::DocComment(nm),
198-
token::Literal(token::Integer(..)) => token::Literal(token::Integer(nm)),
199-
token::Literal(token::Float(..)) => token::Literal(token::Float(nm)),
200-
token::Literal(token::Binary(..)) => token::Literal(token::Binary(nm)),
201-
token::Literal(token::BinaryRaw(..)) => token::Literal(token::BinaryRaw(fix(content),
202-
count(content))),
198+
token::Literal(token::Integer(..), n) => token::Literal(token::Integer(nm), n),
199+
token::Literal(token::Float(..), n) => token::Literal(token::Float(nm), n),
200+
token::Literal(token::Binary(..), n) => token::Literal(token::Binary(nm), n),
201+
token::Literal(token::BinaryRaw(..), n) => token::Literal(token::BinaryRaw(fix(content),
202+
count(content)), n),
203203
token::Ident(..) => token::Ident(ast::Ident { name: nm, ctxt: 0 },
204204
token::ModName),
205205
token::Lifetime(..) => token::Lifetime(ast::Ident { name: nm, ctxt: 0 }),
@@ -214,8 +214,8 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
214214
};
215215

216216
let sp = syntax::codemap::Span {
217-
lo: syntax::codemap::BytePos(from_str::<u32>(start).unwrap() - offset),
218-
hi: syntax::codemap::BytePos(from_str::<u32>(end).unwrap() + 1),
217+
lo: syntax::codemap::BytePos(start.parse::<u32>().unwrap() - offset),
218+
hi: syntax::codemap::BytePos(end.parse::<u32>().unwrap() + 1),
219219
expn_id: syntax::codemap::NO_EXPANSION
220220
};
221221

@@ -247,7 +247,9 @@ fn main() {
247247
let token_map = parse_token_list(token_file.read_to_string().unwrap().as_slice());
248248

249249
let mut stdin = std::io::stdin();
250-
let mut antlr_tokens = stdin.lines().map(|l| parse_antlr_token(l.unwrap().as_slice().trim(),
250+
let mut lock = stdin.lock();
251+
let lines = lock.lines();
252+
let mut antlr_tokens = lines.map(|l| parse_antlr_token(l.unwrap().as_slice().trim(),
251253
&token_map));
252254

253255
let code = File::open(&Path::new(args[1].as_slice())).unwrap().read_to_string().unwrap();
@@ -284,17 +286,17 @@ fn main() {
284286
ref c => assert!(c == &antlr_tok.tok, "{} is not {}", rustc_tok, antlr_tok)
285287
}
286288
)
287-
)
289+
);
288290

289291
matches!(
290-
token::Literal(token::Byte(..)),
291-
token::Literal(token::Char(..)),
292-
token::Literal(token::Integer(..)),
293-
token::Literal(token::Float(..)),
294-
token::Literal(token::Str_(..)),
295-
token::Literal(token::StrRaw(..)),
296-
token::Literal(token::Binary(..)),
297-
token::Literal(token::BinaryRaw(..)),
292+
token::Literal(token::Byte(..), _),
293+
token::Literal(token::Char(..), _),
294+
token::Literal(token::Integer(..), _),
295+
token::Literal(token::Float(..), _),
296+
token::Literal(token::Str_(..), _),
297+
token::Literal(token::StrRaw(..), _),
298+
token::Literal(token::Binary(..), _),
299+
token::Literal(token::BinaryRaw(..), _),
298300
token::Ident(..),
299301
token::Lifetime(..),
300302
token::Interpolated(..),

0 commit comments

Comments
 (0)