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