mirror of https://codeberg.org/topola/topola.git
refactor(specctra-core): merge common.rs into lib.rs
This commit is contained in:
parent
ae006173ce
commit
81a6ec22d0
|
|
@ -1,25 +0,0 @@
|
||||||
pub enum ListToken {
|
|
||||||
Start { name: String },
|
|
||||||
Leaf { value: String },
|
|
||||||
End,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ListToken {
|
|
||||||
pub fn is_start_of(&self, valid_names: &[&'static str]) -> bool {
|
|
||||||
if let Self::Start { name: actual_name } = self {
|
|
||||||
valid_names
|
|
||||||
.iter()
|
|
||||||
.any(|i| i.eq_ignore_ascii_case(actual_name))
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
|
||||||
match &self {
|
|
||||||
Self::Start { name } => 1 + name.len(),
|
|
||||||
Self::Leaf { value } => value.len(),
|
|
||||||
Self::End => 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
//! Module containing the informations about handling the Specctra
|
//! Module about handling the Specctra based file format, and parsing + serializing it
|
||||||
//! based file format, and parsing it into Topola's objects
|
|
||||||
|
|
||||||
mod common;
|
|
||||||
pub use common::*;
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
pub mod mesadata;
|
pub mod mesadata;
|
||||||
|
|
@ -10,3 +7,29 @@ pub mod read;
|
||||||
pub mod rules;
|
pub mod rules;
|
||||||
pub mod structure;
|
pub mod structure;
|
||||||
pub mod write;
|
pub mod write;
|
||||||
|
|
||||||
|
pub enum ListToken {
|
||||||
|
Start { name: String },
|
||||||
|
Leaf { value: String },
|
||||||
|
End,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ListToken {
|
||||||
|
pub fn is_start_of(&self, valid_names: &[&'static str]) -> bool {
|
||||||
|
if let Self::Start { name: actual_name } = self {
|
||||||
|
valid_names
|
||||||
|
.iter()
|
||||||
|
.any(|i| i.eq_ignore_ascii_case(actual_name))
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
match &self {
|
||||||
|
Self::Start { name } => 1 + name.len(),
|
||||||
|
Self::Leaf { value } => value.len(),
|
||||||
|
Self::End => 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use super::common::ListToken;
|
|
||||||
use super::error::{ParseError, ParseErrorContext};
|
use super::error::{ParseError, ParseErrorContext};
|
||||||
use super::structure::Parser;
|
use super::structure::Parser;
|
||||||
|
use super::ListToken;
|
||||||
use utf8_chars::BufReadCharsExt;
|
use utf8_chars::BufReadCharsExt;
|
||||||
|
|
||||||
pub struct InputToken {
|
pub struct InputToken {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use super::common::ListToken;
|
use super::ListToken;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
pub trait WriteSes<W: io::Write> {
|
pub trait WriteSes<W: io::Write> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue