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