Re: [Json] A minimal examplotron-style JSON validation language.

Carsten Bormann <cabo@tzi.org> Wed, 29 May 2019 21:15 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 17CCE1201E2 for <json@ietfa.amsl.com>; Wed, 29 May 2019 14:15:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.198
X-Spam-Level:
X-Spam-Status: No, score=-4.198 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RT_TO-Uzl28c for <json@ietfa.amsl.com>; Wed, 29 May 2019 14:15:12 -0700 (PDT)
Received: from smtp.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 7ED41120041 for <json@ietf.org>; Wed, 29 May 2019 14:15:12 -0700 (PDT)
Received: from [192.168.217.119] (p54A6C998.dip0.t-ipconnect.de [84.166.201.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.uni-bremen.de (Postfix) with ESMTPSA id 45Dk4t15XGzyV4; Wed, 29 May 2019 23:15:10 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <20190529201716.GD11773@localhost>
Date: Wed, 29 May 2019 23:15:09 +0200
Cc: John Cowan <cowan@ccil.org>, Tim Bray <tbray@textuality.com>, JSON WG <json@ietf.org>, Ulysse Carion <ulysse@segment.com>, Rob Sayre <sayrer@gmail.com>
X-Mao-Original-Outgoing-Id: 580857305.2885571-526104fd52d79713ef4b9b70ce148e6d
Content-Transfer-Encoding: quoted-printable
Message-Id: <DD0F8B7F-3D78-43B0-9A92-9D02FFBDC516@tzi.org>
References: <8224451C-F21B-41E5-A834-A9005050CB1F@tzi.org> <CAJK=1RjdYD6TZCNrw=H3d9ZLKLxZZOwVCOYYPwfbP+1ETDDz1Q@mail.gmail.com> <11CDA7F6-30BB-40E4-8926-2EDCBCFD785B@tzi.org> <CAHBU6iv8ZsFM5yco5gi+gcyU8d=u3bOSgiKaF6-hv-GARgNh9w@mail.gmail.com> <CAChr6SwNvG4Z7TKUxAVeH7HMVWiPsEBNb12K9zVkjaGt2_v0fw@mail.gmail.com> <CAHBU6ivTD_v7L-wQ+P9TmSfBY=5N+k-caaZ0TZhg6yZ_SWR_aA@mail.gmail.com> <CAChr6SzD8qdETafQKKU41BcYayTWf+C4GENd9FNzy5JYOv5jRQ@mail.gmail.com> <CAHBU6isx5aB94U-vn_t6GGoQ9W+ATDNYR6_+CtXgOhFho5Qh-g@mail.gmail.com> <20190529144005.GC11773@localhost> <CAD2gp_QELt-3=wqA1gRafNim8Y6fsxZ6hcQmTsoOxCSxU8eM1Q@mail.gmail.com> <20190529201716.GD11773@localhost>
To: Nico Williams <nico@cryptonector.com>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/rNG2srxCzTRt1H27lqnS74A2wZM>
Subject: Re: [Json] A minimal examplotron-style JSON validation language.
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 29 May 2019 21:15:15 -0000

On May 29, 2019, at 22:17, Nico Williams <nico@cryptonector.com> wrote:
> 
>  top_level : choice(file_menu, edit_menu);
>  file_menu : object{"menu"->file_menu_contents};
>  edit_menu : object{"edit_menu"->edit_menu_contents};
>  file_menu_contents := object{
>    "id":"file", /* this means this must be present with this value */
>    "value":"File",
>    "popup": object { ... }
>  };

While it is certainly enjoyable to design another language, I’m not sure why this should not be done in an ABNF-like syntax such as CDDL (which, by the way, is in AUTH48 and will soon be RFC 8610).  
Keeping your names (even the snake case, where I’d be using kebab case):

top_level = file_menu / edit_menu
file_menu = { menu: file_menu_contents }
edit_menu = { edit_menu: edit_menu_contents }
file_menu_contents = {
  id: text    ; assuming here this is your examplotron content
  value: text
  popup: { }
}
edit_menu_contents = { }

I didn’t put in the ignore-unknown stuff; that would be 12 characters in CDDL unless you define something to make this shorter.

Put the above into a menus.cddl and try

  cddl menus.cddl g 10

you get 10 examples:

{"menu": {"id": "gray", "value": "commixt", "popup": {}}}
{"menu": {"id": "proctoplasty", "value": "compunctious", "popup": {}}}
{"menu": {"id": "taglike", "value": "valvulate", "popup": {}}}
{"edit_menu": {}}
{"menu": {"id": "uninundated", "value": "unworthily", "popup": {}}}
{"edit_menu": {}}
{"edit_menu": {}}
{"menu": {"id": "Orangeist", "value": "imperialin", "popup": {}}}
{"edit_menu": {}}
{“edit_menu": {}}

This is a bit boring as there is only one choice and two non-singleton types.
Sorry if I didn’t get the intent of your example right.

Grüße, Carsten

PS.: OK, with ignore-unknown:

top_level = file_menu / edit_menu
file_menu = { menu: file_menu_contents _..._ }
edit_menu = { edit_menu: edit_menu_contents _..._ }
file_menu_contents = {
  id: text    ; I'm assuming here this is your examplotron content
  value: text
  popup: { _..._ }
  _..._
}
edit_menu_contents = { _..._ }

_..._ = ( * text => any )

➔ 

{"menu": {"id": "fahlerz", "value": "unshocked", "popup": {"astrophotometry": "perdurance"}, "foolship": "pentacosane", "larrikin": "myoglobin"}}
{"edit_menu": {"priggery": "cordaitean", "jackpudding": "righten", "unconfidence": "photolitho", "reviling": "ewe"}, "allophylic": "compound", "teacupful": "allergen"}
{"menu": {"id": "amazement", "value": "condylomatous", "popup": {"cosounding": "share", "contribute": "gabblement", "gunpaper": "dividualism", "undersociety": "noration"}}}
{"edit_menu": {"glareole": "clicket", "madling": "dizain"}, "scrimpily": "gypsywort", "neurofibrilla": "discolor"}
{"edit_menu": {"unpermissive": "cockneity"}, "caudillism": "visa", "interloop": "anthracnose"}
{"menu": {"id": "blankite", "value": "puffery", "popup": {"katuka": "Gnathostomata", "effeteness": "unspelt"}}, "Chaldaic": "extrafoliaceous", "trimesic": "dwindlement", "successful": "fluctuant", "nevadite": "aggradational"}
{"menu": {"id": "acrostolion", "value": "devocalize", "popup": {}}, "cymation": "premanufacturer", "mysticete": "analyst", "ethnocentric": "Myrtales"}
{"edit_menu": {"glycerolize": "blastoid", "undisputedness": "propheticly"}, "orchiotomy": "illiquidity"}
{"menu": {"id": "tenebriously", "value": "guardo", "popup": {"abeigh": "fibrillar", "Sminthurus": "disnosed", "accessibility": "autem"}}}
{"edit_menu": {"stableman": "erosional"}}