Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YamlLoader::load_from_str_with_markers to provide AST with source markers #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ repository = "https://github.com/chyh1990/yaml-rust"
readme = "README.md"

[dependencies]
derivative = "1"
linked-hash-map = ">=0.0.9, <0.6"

[dev-dependencies]
indoc = "0.3"
quickcheck = "0.7"
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! # Examples
//!
//! ```
//! use yaml_rust::{YamlLoader, YamlEmitter};
//! use yaml_rust::{YamlLoader, YamlEmitter, YamlNode};
//!
//! let docs = YamlLoader::load_from_str("[1, 2, 3]").unwrap();
//! let doc = &docs[0]; // select the first document
Expand All @@ -44,6 +44,7 @@
allow(match_same_arms, should_implement_trait)
)]

extern crate derivative;
extern crate linked_hash_map;

pub mod emitter;
Expand All @@ -54,8 +55,8 @@ pub mod yaml;
// reexport key APIs
pub use emitter::{EmitError, YamlEmitter};
pub use parser::Event;
pub use scanner::ScanError;
pub use yaml::{Yaml, YamlLoader};
pub use scanner::{Marker, ScanError};
pub use yaml::{Node, Yaml, YamlLoader, YamlMarked, YamlNode};

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum TScalarStyle {
Foled,
}

#[derive(Clone, Copy, PartialEq, Debug, Eq)]
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug, Eq, Ord, Hash)]
pub struct Marker {
index: usize,
line: usize,
Expand Down
Loading