Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kcov*
**/*.rs.bk
tags
**/*.rustfmt
Cargo.lock
Cargo.lock
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ repository = "https://github.com/ithinuel/async-gcode"
categories = ["asynchronous", "embedded", "no-std", "parsing"]

[features]
default = ["std"]
std = []
default = ["std", "future-stream"]
std = ["float-f64"]
parse-comments = []
parse-trailing-comment = []
parse-checksum = []
parse-parameters = []
parse-expressions = []
optional-value = []
string-value = []
float-f64 = []
# Use future::stream as input interface. If not set, async-traits will be used insted.
future-stream = ["pin-project-lite", "futures"]

[badges]
maintenance = { status = "experimental" }

[dev-dependencies]
futures-executor = { version = "0.3.21" }
futures-executor = { version = "0.3" }

[dependencies]
either = {version = "^1", default-features = false }
futures = { version = "0.3.21", default-features = false }
pin-project-lite = { version = "0.2.9" }
futures = { version = "0.3", optional = true, default-features = false }
pin-project-lite = { version = "0.2", optional = true }
6 changes: 5 additions & 1 deletion examples/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ fn main() {
));

while let Some(res) = parser.next().await {
println!("{:?}", res);
match res {
Ok(_r) => println!("{:?}", _r),
Err(Error::Io(_ie)) => println!("IOError {:?}", _ie),
Err(Error::Parse(_pe)) => println!("ParseError {:?}", _pe),
}
}
});
}
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ mod types;

mod parser;

pub use stream::{ByteStream, TryByteStream};
pub use parser::AsyncParserState;
pub use parser::Parser;
pub use types::Literal;
pub use types::RealValue;

pub use types::DecimalRepr;

#[cfg(any(feature = "parse-expressions", feature = "parse-parameters"))]
pub use types::expressions::Expression;

Expand All @@ -110,9 +114,12 @@ pub enum Error {
/// Error no the gcode syntax
UnexpectedByte(u8),

/// The parsed number excedded the expected range.
/// The parsed number exceeded the expected range.
NumberOverflow,

/// Incompatible number conversions.
InvalidNumberConversion,

/// Format error during number parsing. Typically a dot without digits (at least one is
/// required).
BadNumberFormat,
Expand All @@ -132,11 +139,14 @@ pub enum Error {

#[derive(Debug, PartialEq, Clone)]
pub enum GCode {
StatusCommand,
BlockDelete,
LineNumber(u32),
LineNumber(Option<u32>),
#[cfg(feature = "parse-comments")]
Comment(String),
Word(char, RealValue),
#[cfg(feature = "string-value")]
Text(RealValue),
#[cfg(feature = "parse-parameters")]
/// When `optional-value` is enabled, the index cannot be `RealValue::None`.
ParameterSet(RealValue, RealValue),
Expand Down
Loading