Skip to content

Commit

Permalink
Use json-syntax 0.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Apr 2, 2024
1 parent 53a3a6e commit d2f7eb3
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ langtag = "0.4.0"
thiserror = "1.0.50"
serde = "1.0.192"
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
json-syntax = { git = "https://github.com/timothee-haudebourg/json-syntax.git", rev = "b066e62" }
json-syntax = "0.12.3"
codespan-reporting = "0.11.1"

locspan = "0.8.2"
Expand Down
4 changes: 2 additions & 2 deletions layouts/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ fn main() -> ExitCode {
}

fn load_file(files: &SimpleFiles<String, String>, file_id: usize) -> bool {
use json_syntax::{Parse, TryFromJsonSyntax};
use json_syntax::{Parse, TryFromJson};

match json_syntax::Value::parse_str(files.get(file_id).unwrap().source().as_str()) {
Ok((json, code_map)) => {
match treeldr_layouts::abs::syntax::Layout::try_from_json_syntax(&json, &code_map) {
match treeldr_layouts::abs::syntax::Layout::try_from_json(&json, &code_map) {
Ok(_layout) => true,
Err(e) => {
let span = code_map.get(e.position()).unwrap().span;
Expand Down
6 changes: 3 additions & 3 deletions layouts/src/abs/regexp.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use btree_range_map::RangeSet;
use json_syntax::TryFromJsonSyntax;
use json_syntax::TryFromJson;
use std::{fmt, str::FromStr};

use crate::utils::{Automaton, DetAutomaton};

use super::syntax::{expect_string, Error};

impl TryFromJsonSyntax for RegExp {
impl TryFromJson for RegExp {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
_code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down
20 changes: 10 additions & 10 deletions layouts/src/abs/syntax/dataset.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use json_syntax::TryFromJsonSyntax;
use json_syntax::TryFromJson;
use serde::{Deserialize, Serialize};

use super::{expect_array, Build, BuildError, Context, Error, Pattern, Scope};
Expand All @@ -19,15 +19,15 @@ impl From<Vec<Quad>> for Dataset {
}
}

impl TryFromJsonSyntax for Dataset {
impl TryFromJson for Dataset {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
) -> Result<Self, Self::Error> {
Vec::try_from_json_syntax_at(json, code_map, offset).map(Self)
Vec::try_from_json_at(json, code_map, offset).map(Self)
}
}

Expand Down Expand Up @@ -55,10 +55,10 @@ pub struct Quad(
#[serde(default, skip_serializing_if = "Option::is_none")] pub Option<Pattern>,
);

impl TryFromJsonSyntax for Quad {
impl TryFromJson for Quad {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand All @@ -74,15 +74,15 @@ impl TryFromJsonSyntax for Quad {
}

let mut component_offset = offset + 1;
let s = Pattern::try_from_json_syntax_at(&array[0], code_map, component_offset)?;
let s = Pattern::try_from_json_at(&array[0], code_map, component_offset)?;
component_offset += code_map.get(component_offset).unwrap().volume;
let p = Pattern::try_from_json_syntax_at(&array[1], code_map, component_offset)?;
let p = Pattern::try_from_json_at(&array[1], code_map, component_offset)?;
component_offset += code_map.get(component_offset).unwrap().volume;
let o = Pattern::try_from_json_syntax_at(&array[2], code_map, component_offset)?;
let o = Pattern::try_from_json_at(&array[2], code_map, component_offset)?;
component_offset += code_map.get(component_offset).unwrap().volume;
let g = array
.get(3)
.map(|g| Pattern::try_from_json_syntax_at(g, code_map, component_offset))
.map(|g| Pattern::try_from_json_at(g, code_map, component_offset))
.transpose()?;

Ok(Self(s, p, o, g))
Expand Down
10 changes: 5 additions & 5 deletions layouts/src/abs/syntax/layout/list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use json_syntax::{Kind, TryFromJsonObject, TryFromJsonSyntax};
use json_syntax::{Kind, TryFromJson, TryFromJsonObject};
use rdf_types::{dataset::BTreeDataset, RDF_FIRST, RDF_REST};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -138,10 +138,10 @@ pub enum ListNodeOrLayout {
Layout(LayoutRef),
}

impl TryFromJsonSyntax for ListNodeOrLayout {
impl TryFromJson for ListNodeOrLayout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -383,10 +383,10 @@ pub struct ListItem {
pub property: Option<Pattern>,
}

impl TryFromJsonSyntax for ListItem {
impl TryFromJson for ListItem {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down
6 changes: 3 additions & 3 deletions layouts/src/abs/syntax/layout/literal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use json_syntax::{TryFromJsonObject, TryFromJsonSyntax};
use json_syntax::{TryFromJson, TryFromJsonObject};
use serde::{Deserialize, Serialize};

use crate::{
Expand Down Expand Up @@ -106,10 +106,10 @@ impl DataLayout {
}
}

impl TryFromJsonSyntax for DataLayout {
impl TryFromJson for DataLayout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down
32 changes: 14 additions & 18 deletions layouts/src/abs/syntax/layout/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt;
use iref::IriBuf;
use json_syntax::{Kind, TryFromJsonObject, TryFromJsonSyntax};
use json_syntax::{Kind, TryFromJson, TryFromJsonObject};
use rdf_types::{
generator,
interpretation::{IriInterpretationMut, LiteralInterpretationMut},
Expand Down Expand Up @@ -145,10 +145,10 @@ impl Layout {
}
}

impl TryFromJsonSyntax for Layout {
impl TryFromJson for Layout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -295,10 +295,10 @@ impl TryFromJsonObject for LayoutRef {
}
}

impl TryFromJsonSyntax for LayoutRef {
impl TryFromJson for LayoutRef {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -373,17 +373,15 @@ impl From<Vec<String>> for LayoutInput {
}
}

impl TryFromJsonSyntax for LayoutInput {
impl TryFromJson for LayoutInput {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
) -> Result<Self, Self::Error> {
Ok(Self(OneOrMany::try_from_json_syntax_at(
json, code_map, offset,
)?))
Ok(Self(OneOrMany::try_from_json_at(json, code_map, offset)?))
}
}

Expand Down Expand Up @@ -471,17 +469,15 @@ impl ExtraProperties {
}
}

impl TryFromJsonSyntax for ExtraProperties {
impl TryFromJson for ExtraProperties {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
) -> Result<Self, Self::Error> {
Ok(Self(BTreeMap::try_from_json_syntax_at(
json, code_map, offset,
)?))
Ok(Self(BTreeMap::try_from_json_at(json, code_map, offset)?))
}
}

Expand Down Expand Up @@ -540,15 +536,15 @@ impl From<Vec<Pattern>> for ValueInput {
}
}

impl TryFromJsonSyntax for ValueInput {
impl TryFromJson for ValueInput {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
) -> Result<Self, Self::Error> {
OneOrMany::try_from_json_syntax_at(json, code_map, offset).map(Self)
OneOrMany::try_from_json_at(json, code_map, offset).map(Self)
}
}

Expand Down
10 changes: 5 additions & 5 deletions layouts/src/abs/syntax/layout/product.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;

use json_syntax::{TryFromJsonObject, TryFromJsonSyntax};
use json_syntax::{TryFromJson, TryFromJsonObject};
use serde::{Deserialize, Serialize};

use crate::abs::{
Expand All @@ -26,10 +26,10 @@ pub struct ProductLayout {
pub fields: BTreeMap<String, Field>,
}

impl TryFromJsonSyntax for ProductLayout {
impl TryFromJson for ProductLayout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -128,10 +128,10 @@ pub struct Field {
pub required: bool,
}

impl TryFromJsonSyntax for Field {
impl TryFromJson for Field {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down
26 changes: 13 additions & 13 deletions layouts/src/abs/syntax/layout/sum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;

use json_syntax::{Kind, TryFromJsonObject, TryFromJsonSyntax};
use json_syntax::{Kind, TryFromJson, TryFromJsonObject};
use serde::{Deserialize, Serialize};

use crate::abs::{
Expand All @@ -26,10 +26,10 @@ pub struct SumLayout {
pub variants: BTreeMap<String, Variant>,
}

impl TryFromJsonSyntax for SumLayout {
impl TryFromJson for SumLayout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -68,10 +68,10 @@ pub struct Variant {
pub dataset: Dataset,
}

impl TryFromJsonSyntax for Variant {
impl TryFromJson for Variant {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -135,10 +135,10 @@ pub enum VariantFormatOrLayout {
Layout(LayoutRef),
}

impl TryFromJsonSyntax for VariantFormatOrLayout {
impl TryFromJson for VariantFormatOrLayout {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand All @@ -151,7 +151,7 @@ impl TryFromJsonSyntax for VariantFormatOrLayout {
if value.contains_key("type") {
LayoutRef::try_from_json_object_at(value, code_map, offset).map(Self::Layout)
} else {
VariantFormat::try_from_json_syntax_at(json, code_map, offset).map(Self::Format)
VariantFormat::try_from_json_at(json, code_map, offset).map(Self::Format)
}
}
other => Err(Error::Unexpected {
Expand Down Expand Up @@ -193,10 +193,10 @@ pub struct VariantFormat {
pub graph: Option<Option<Pattern>>,
}

impl TryFromJsonSyntax for VariantFormat {
impl TryFromJson for VariantFormat {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
Expand Down Expand Up @@ -281,14 +281,14 @@ impl From<Vec<Pattern>> for VariantInput {
}
}

impl TryFromJsonSyntax for VariantInput {
impl TryFromJson for VariantInput {
type Error = Error;

fn try_from_json_syntax_at(
fn try_from_json_at(
json: &json_syntax::Value,
code_map: &json_syntax::CodeMap,
offset: usize,
) -> Result<Self, Self::Error> {
OneOrMany::try_from_json_syntax_at(json, code_map, offset).map(Self)
OneOrMany::try_from_json_at(json, code_map, offset).map(Self)
}
}
Loading

0 comments on commit d2f7eb3

Please sign in to comment.