From 15e477a04d5f97927a6fd233d1283fcd093325d9 Mon Sep 17 00:00:00 2001 From: Edgar Date: Tue, 23 Jan 2024 10:59:53 -0300 Subject: [PATCH] readme --- README.md | 15 +++++++++++++++ src/ast.rs | 5 +---- src/lib.rs | 7 +++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3974a0a --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# lalrpop-json +A JSON parser using lalrpop. + +```rust + +use lalrpop_json::{parse_value, Value}; + +let value: Value = parse_value(r#" +{ + "hello": "world", + "array": ["first", 2, true, false, null, { "more": 2 }] +} +"#).unwrap(); + +``` diff --git a/src/ast.rs b/src/ast.rs index de90ea0..0bac551 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; - #[derive(Debug, Clone, Copy)] pub struct Span { pub lo: usize, @@ -9,9 +8,7 @@ pub struct Span { impl Span { pub fn new(lo: usize, hi: usize) -> Self { - Self { - lo, hi - } + Self { lo, hi } } } diff --git a/src/lib.rs b/src/lib.rs index 0e75340..5d6c005 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,5 +43,12 @@ mod test { #[test] fn test_value() { parse_value(r#"{ "hello": "world", "a": [2, "s"] }"#).unwrap(); + parse_value( + r#"{ + "hello": "world", + "array": ["first", 2, true, false, null, { "more": 2 }] + }"#, + ) + .unwrap(); } }