@@ -61,7 +61,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
61
61
"SHL" => token:: BinOp ( token:: Shl ) ,
62
62
"LBRACE" => token:: OpenDelim ( token:: Brace ) ,
63
63
"RARROW" => token:: RArrow ,
64
- "LIT_STR" => token:: Literal ( token:: Str_ ( Name ( 0 ) ) ) ,
64
+ "LIT_STR" => token:: Literal ( token:: Str_ ( Name ( 0 ) ) , None ) ,
65
65
"DOTDOT" => token:: DotDot ,
66
66
"MOD_SEP" => token:: ModSep ,
67
67
"DOTDOTDOT" => token:: DotDotDot ,
@@ -71,7 +71,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
71
71
"ANDAND" => token:: AndAnd ,
72
72
"AT" => token:: At ,
73
73
"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 ) ,
75
75
"RPAREN" => token:: CloseDelim ( token:: Paren ) ,
76
76
"SLASH" => token:: BinOp ( token:: Slash ) ,
77
77
"COMMA" => token:: Comma ,
@@ -80,8 +80,8 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
80
80
"TILDE" => token:: Tilde ,
81
81
"IDENT" => id ( ) ,
82
82
"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 ) ,
85
85
"EQ" => token:: Eq ,
86
86
"RBRACKET" => token:: CloseDelim ( token:: Bracket ) ,
87
87
"COMMENT" => token:: Comment ,
@@ -95,9 +95,9 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
95
95
"BINOP" => token:: BinOp ( token:: Plus ) ,
96
96
"POUND" => token:: Pound ,
97
97
"OROR" => token:: OrOr ,
98
- "LIT_INTEGER" => token:: Literal ( token:: Integer ( Name ( 0 ) ) ) ,
98
+ "LIT_INTEGER" => token:: Literal ( token:: Integer ( Name ( 0 ) ) , None ) ,
99
99
"BINOPEQ" => token:: BinOpEq ( token:: Plus ) ,
100
- "LIT_FLOAT" => token:: Literal ( token:: Float ( Name ( 0 ) ) ) ,
100
+ "LIT_FLOAT" => token:: Literal ( token:: Float ( Name ( 0 ) ) , None ) ,
101
101
"WHITESPACE" => token:: Whitespace ,
102
102
"UNDERSCORE" => token:: Underscore ,
103
103
"MINUS" => token:: BinOp ( token:: Minus ) ,
@@ -107,8 +107,8 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
107
107
"OR" => token:: BinOp ( token:: Or ) ,
108
108
"GT" => token:: Gt ,
109
109
"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 ) ,
112
112
_ => continue ,
113
113
} ;
114
114
@@ -189,17 +189,17 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
189
189
token:: BinOp ( ..) => token:: BinOp ( str_to_binop ( content) ) ,
190
190
token:: BinOpEq ( ..) => token:: BinOpEq ( str_to_binop ( content. slice_to (
191
191
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 ) ,
197
197
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 ) ,
203
203
token:: Ident ( ..) => token:: Ident ( ast:: Ident { name : nm, ctxt : 0 } ,
204
204
token:: ModName ) ,
205
205
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
214
214
} ;
215
215
216
216
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 ) ,
219
219
expn_id : syntax:: codemap:: NO_EXPANSION
220
220
} ;
221
221
@@ -247,7 +247,9 @@ fn main() {
247
247
let token_map = parse_token_list ( token_file. read_to_string ( ) . unwrap ( ) . as_slice ( ) ) ;
248
248
249
249
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 ( ) ,
251
253
& token_map) ) ;
252
254
253
255
let code = File :: open ( & Path :: new ( args[ 1 ] . as_slice ( ) ) ) . unwrap ( ) . read_to_string ( ) . unwrap ( ) ;
@@ -284,17 +286,17 @@ fn main() {
284
286
ref c => assert!( c == & antlr_tok. tok, "{} is not {}" , rustc_tok, antlr_tok)
285
287
}
286
288
)
287
- )
289
+ ) ;
288
290
289
291
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 ( ..) , _ ) ,
298
300
token:: Ident ( ..) ,
299
301
token:: Lifetime ( ..) ,
300
302
token:: Interpolated ( ..) ,
0 commit comments