mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: EdnItem -> Atom, rewrite tokenizer
This commit is contained in:
parent
143cd24e09
commit
ff31957fed
39 changed files with 477 additions and 376 deletions
|
|
@ -1,37 +1,39 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_fn_trait_return)]
|
||||
mod edn_error; pub use self::edn_error::*;
|
||||
mod edn_item; pub use self::edn_item::*;
|
||||
//mod edn_iter; pub use self::edn_iter::*;
|
||||
mod edn_token; pub use self::edn_token::*;
|
||||
mod edn_provide; pub use self::edn_provide::*;
|
||||
mod try_from_edn; pub use self::try_from_edn::*;
|
||||
pub(crate) use std::{fmt::{Debug, Display, Formatter, Error as FormatError}};
|
||||
#[cfg(test)] #[test] fn test_edn () -> Result<(), ParseError> {
|
||||
use EdnItem::*;
|
||||
assert_eq!(EdnItem::<String>::read_all("")?,
|
||||
mod token; pub use self::token::*;
|
||||
mod provide; pub use self::provide::*;
|
||||
mod describe; pub use self::describe::*;
|
||||
pub(crate) use std::fmt::{Debug, Display, Formatter, Error as FormatError};
|
||||
pub(crate) use std::sync::Arc;
|
||||
#[cfg(test)] #[test] fn test_lang () -> Result<(), ParseError> {
|
||||
use Atom::*;
|
||||
assert_eq!(Atom::read_all("")?,
|
||||
vec![]);
|
||||
assert_eq!(EdnItem::<String>::read_all(" ")?,
|
||||
assert_eq!(Atom::read_all(" ")?,
|
||||
vec![]);
|
||||
assert_eq!(EdnItem::<String>::read_all("1234")?,
|
||||
assert_eq!(Atom::read_all("1234")?,
|
||||
vec![Num(1234)]);
|
||||
assert_eq!(EdnItem::<String>::read_all("1234 5 67")?,
|
||||
assert_eq!(Atom::read_all("1234 5 67")?,
|
||||
vec![Num(1234), Num(5), Num(67)]);
|
||||
assert_eq!(EdnItem::<String>::read_all("foo/bar")?,
|
||||
assert_eq!(Atom::read_all("foo/bar")?,
|
||||
vec![Key("foo/bar".into())]);
|
||||
assert_eq!(EdnItem::<String>::read_all(":symbol")?,
|
||||
assert_eq!(Atom::read_all(":symbol")?,
|
||||
vec![Sym(":symbol".into())]);
|
||||
assert_eq!(EdnItem::<String>::read_all(" foo/bar :baz 456")?,
|
||||
assert_eq!(Atom::read_all(" foo/bar :baz 456")?,
|
||||
vec![Key("foo/bar".into()), Sym(":baz".into()), Num(456)]);
|
||||
assert_eq!(EdnItem::<String>::read_all(" (foo/bar :baz 456) ")?,
|
||||
assert_eq!(Atom::read_all(" (foo/bar :baz 456) ")?,
|
||||
vec![Exp(vec![Key("foo/bar".into()), Sym(":baz".into()), Num(456)])]);
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(test)] #[test] fn test_edn_layout () -> Result<(), ParseError> {
|
||||
EdnItem::<String>::read_all(include_str!("../../output/examples/edn01.edn"))?;
|
||||
EdnItem::<String>::read_all(include_str!("../../output/examples/edn02.edn"))?;
|
||||
//panic!("{layout:?}");
|
||||
//let content = <dyn EdnViewData<::tek_engine::tui::Tui>>::from(&layout);
|
||||
#[cfg(test)] #[test] fn test_lang_examples () -> Result<(), ParseError> {
|
||||
for example in [
|
||||
include_str!("../../tui/examples/edn01.edn"),
|
||||
include_str!("../../tui/examples/edn02.edn"),
|
||||
] {
|
||||
let items = Atom::read_all(example)?;
|
||||
//panic!("{layout:?}");
|
||||
//let content = <dyn EdnViewData<::tek_engine::tui::Tui>>::from(&layout);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
#[macro_export] macro_rules! from_edn {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue