mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Fix slightly too eager parsing of aliases
This commit is contained in:
parent
c136c8a216
commit
15228a373b
2 changed files with 21 additions and 0 deletions
17
src/bin/tokens.rs
Normal file
17
src/bin/tokens.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
extern crate units_rs;
|
||||
|
||||
use units_rs::*;
|
||||
|
||||
fn main() {
|
||||
use std::io::Read;
|
||||
use std::fs::File;
|
||||
|
||||
let mut f = File::open("units.txt").unwrap();
|
||||
let mut buf = vec![];
|
||||
f.read_to_end(&mut buf).unwrap();
|
||||
let string = String::from_utf8_lossy(&*buf);
|
||||
let mut iter = unit_defs::TokenIterator::new(&*string).peekable();
|
||||
let res = unit_defs::tokens(&mut iter);
|
||||
|
||||
println!("{:#?}", res);
|
||||
}
|
|
@ -223,6 +223,10 @@ fn parse_unknown(mut iter: &mut Iter) {
|
|||
}
|
||||
|
||||
fn parse_alias(mut iter: &mut Iter) -> Option<(Expr, String)> {
|
||||
match *iter.peek().unwrap() {
|
||||
Token::Newline | Token::Comment | Token::Eof => return None,
|
||||
_ => ()
|
||||
}
|
||||
let expr = parse_expr(iter);
|
||||
match iter.next().unwrap() {
|
||||
Token::TriplePipe => (),
|
||||
|
|
Loading…
Reference in a new issue