2019-11-03 18:00:00 -06:00
|
|
|
// check-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-03-17 15:33:26 -05:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{self, BufReader, Read};
|
2014-10-16 14:40:21 -05:00
|
|
|
|
2015-03-17 15:33:26 -05:00
|
|
|
struct Lexer<R: Read>
|
2014-10-16 14:40:21 -05:00
|
|
|
{
|
2015-03-17 15:33:26 -05:00
|
|
|
reader: BufReader<R>,
|
2014-10-16 14:40:21 -05:00
|
|
|
}
|
|
|
|
|
2015-03-17 15:33:26 -05:00
|
|
|
impl<R: Read> Lexer<R>
|
2014-10-16 14:40:21 -05:00
|
|
|
{
|
|
|
|
pub fn new_from_reader(r: R) -> Lexer<R>
|
|
|
|
{
|
2015-03-17 15:33:26 -05:00
|
|
|
Lexer{reader: BufReader::new(r)}
|
2014-10-16 14:40:21 -05:00
|
|
|
}
|
|
|
|
|
2015-03-17 15:33:26 -05:00
|
|
|
pub fn new_from_file(p: &str) -> io::Result<Lexer<File>>
|
2014-10-16 14:40:21 -05:00
|
|
|
{
|
2016-03-22 22:01:37 -05:00
|
|
|
Ok(Lexer::new_from_reader(File::open(p)?))
|
2014-10-16 14:40:21 -05:00
|
|
|
}
|
|
|
|
|
2015-03-17 15:33:26 -05:00
|
|
|
pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]>
|
2014-10-16 14:40:21 -05:00
|
|
|
{
|
2015-03-17 15:33:26 -05:00
|
|
|
Lexer::new_from_reader(s.as_bytes())
|
2014-10-16 14:40:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|