mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
TokenIter -> SourceIter, reuse logic in operators, and now it renders correctly!
This commit is contained in:
parent
266f59085e
commit
b8726de78f
13 changed files with 203 additions and 154 deletions
|
|
@ -53,37 +53,37 @@ pub(crate) use std::fmt::{Debug, Display, Formatter, Result as FormatResult, Err
|
|||
assert_eq!(token, Token { source, start: 0, length: 4, value: Sym(":f00") });
|
||||
|
||||
let src = "";
|
||||
assert_eq!(None, TokenIter(src).next());
|
||||
assert_eq!(None, SourceIter(src).next());
|
||||
|
||||
let src = " \n \r \t ";
|
||||
assert_eq!(None, TokenIter(src).next());
|
||||
assert_eq!(None, SourceIter(src).next());
|
||||
|
||||
let src = "7";
|
||||
assert_eq!(Num(7), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Num(7), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = " 100 ";
|
||||
assert_eq!(Num(100), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Num(100), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = " 9a ";
|
||||
assert_eq!(Err(Unexpected('a')), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Err(Unexpected('a')), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = " :123foo ";
|
||||
assert_eq!(Sym(":123foo"), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Sym(":123foo"), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = " \r\r\r\n\n\n@bar456\t\t\t\t\t\t";
|
||||
assert_eq!(Sym("@bar456"), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Sym("@bar456"), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = "foo123";
|
||||
assert_eq!(Key("foo123"), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Key("foo123"), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
let src = "foo/bar";
|
||||
assert_eq!(Key("foo/bar"), TokenIter(src).next().unwrap().0.value);
|
||||
assert_eq!(Key("foo/bar"), SourceIter(src).next().unwrap().0.value);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(test)] #[test] fn test_examples () -> Result<(), ParseError> {
|
||||
let src = include_str!("../../tek/src/view_arranger.edn");
|
||||
let mut view = TokenIter(src);
|
||||
let mut view = SourceIter(src);
|
||||
assert_eq!(view.0, src);
|
||||
let mut expr = view.peek();
|
||||
assert_eq!(view.0, src);
|
||||
|
|
@ -91,7 +91,7 @@ pub(crate) use std::fmt::{Debug, Display, Formatter, Result as FormatResult, Err
|
|||
source: src,
|
||||
start: 0,
|
||||
length: src.len(),
|
||||
value: Exp(0, TokenIter(&src[1..]))
|
||||
value: Exp(0, SourceIter(&src[1..]))
|
||||
}));
|
||||
//panic!("{view:?}");
|
||||
//panic!("{:#?}", expr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue