Re: JSON-LD grammar

On Jan 4, 2013, at 9:51 AM, Markus Lanthaler <markus.lanthaler@gmx.net> wrote:

> As announced in the last mail, I've just fixed the last remaining issues in
> the JSON-LD Grammar section. It definitely does the job, I was just
> wondering whether we should also include a more formal, ABNF-like grammar
> (or maybe even replace the prose). Unfortunately it seems that currently
> there's no accepted way or best-practice to specify JSON "grammars" (the
> JSON Schema Internet Draft expired two years ago [1]).

AFAIK, W3C standard is EBNF, and I did make an attempt at an EBNF grammar some time ago, but the consensus of the group was that this wasn't too useful. The fact that it's JSON, and pretty much every implementation will use a JSON parser and iterate of the resulting objects, I still think this is probably not too useful for the purposes of implementing a processor.

However, I can see that laying out different node types, and what the expected key/value pairs that can be expected. As you note, we do this in prose now, but something that is more visual might be easier for people to understand. For this purpose, we can probably invent our own nomenclature, as long as it's consistent and light-weight. What you have below is pretty easy to understand, IMO.

I don't think we should entirely get rid of the descriptive text, though.

Gregg

> So I tried to come up with something ABNF-like (it's not valid ABNF) and
> would be interested in hearing your opinions. I'm not sure myself yet
> whether that helps or confuses people.
> 
> graph = node-obj / node-obj[]
> 
> node-obj =
>    {
>        "@context": context-def       (0..1)
>        "@id": string                 (0..1)
>        "@type": iri / iri[]          (0..1)
>        "@graph": graph               (0..1)
>        "@annotation": string         (0..1)
>        property-key: property-value / property-value[] /
>                      language-map / annotation-map  (*)
>    }
> 
> value-obj =
>    {
>        "@context": context-def    (0..1)
>        "@value": scalar           (0..1)
>        "@language": bcp47-tag / "@type": iri    (0..1)
>        "@annotation": string
>     }
> 
> list-obj =
>    {
>        "@context": context-def       (0..1)
>        "@list": list-set-value / list-set-value[]  (1)
>        "@annotation": string         (0..1)
>    }
> 
> set-obj =
>    {
>        "@context": context-def       (0..1)
>        "@set": list-set-value / list-set-value[]  (1)
>        "@annotation": string         (0..1)
>    }
> 
> language-map =
>    {
>        "@context": context-def       (0..1)
>        bcp47-tag: string / string[]  (*)
>    }
> 
> annotation-map =
>    {
>        "@context": context-def       (0..1)
>        string: property-value / property-value[]   (*)
>    }
> 
> list-set-value = scalar / node-obj / value-obj
> 
> property-value = list-set-value / list-obj / set-obj
> 
> context-def = null / iri / context-def-obj /
>              (null / iri / context-def-obj)[]
> 
> context-def-obj =
>    {
>        property-key: null / iri / term-def-obj   (*)
>        "@language": bcp47-tag      (0..1)
>        "@vocab": iri               (0..1)
>    }
> 
> term-def-obj =
>    {
>        "@id": iri    (0..1)
>        "@language": bcp47-tag / "@type": iri    (0..1)
>        "@container": ( "@list" / "@set" / 
>                        "@language" / "@annotation" )   (0..1)
>    }
> 
> bcp47-tag = string   ; should this be more explicit?
> 
> iri = string         ; should this be more explicit?
> 
> property-key = string - keyword  ; any string except a keyword
> 
> keyword = @context / @id / @value / @language / @type /
>          @container / @list / @set / @annotation / @vocab / @graph
> 
> scalar = null / string / number / true / false
> 
> 
> 
> [1] http://tools.ietf.org/html/draft-zyp-json-schema-03
> 
> 
> Cheers,
> Markus
> 
> 
> 
> --
> Markus Lanthaler
> @markuslanthaler
> 
> 

Received on Monday, 7 January 2013 18:30:41 UTC