This commit is contained in:
Edgar 2024-01-23 10:59:53 -03:00
parent 9b5cae664b
commit 15e477a04d
3 changed files with 23 additions and 4 deletions

15
README.md Normal file
View file

@ -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();
```

View file

@ -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 }
}
}

View file

@ -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();
}
}