[netmod] whitespace stripping

Ladislav Lhotka <lhotka@nic.cz> Fri, 09 January 2015 10:26 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2EEA91A8741 for <netmod@ietfa.amsl.com>; Fri, 9 Jan 2015 02:26:01 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.661
X-Spam-Level:
X-Spam-Status: No, score=-0.661 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HELO_EQ_CZ=0.445, HOST_EQ_CZ=0.904, T_RP_MATCHES_RCVD=-0.01] autolearn=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 7-Z1aiSmOtQ8 for <netmod@ietfa.amsl.com>; Fri, 9 Jan 2015 02:25:59 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 84BB01A8740 for <netmod@ietf.org>; Fri, 9 Jan 2015 02:25:59 -0800 (PST)
Received: from [195.113.220.110] (unknown [195.113.220.110]) by mail.nic.cz (Postfix) with ESMTPSA id 08FE013FCB8 for <netmod@ietf.org>; Fri, 9 Jan 2015 11:25:58 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nic.cz; s=default; t=1420799158; bh=v00W+WdzoSP5S67yh9GEAfBX9wffkwye+Xor2rrBf1Y=; h=From:Content-Type:Content-Transfer-Encoding:Subject:Message-Id: Date:To:Mime-Version; b=dmOHQThmAS4lbnai4oHn7E9D+0I7UqTxlunOyPwtTVORwc4BX/x+Me/sCinhMyWFY odZbAgGJpsjRcdPQKyFqNigd7bt9nvEEOZ47dEtUhGDQIBNog6piJEZRaVbR3Zc0tY iA6+59G9TKZaIH7YvofXNt+bCbHm2T/IT6h3gOO8=
From: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Message-Id: <F7BAD819-9874-40BF-91C9-DFF44F1A0728@nic.cz>
Date: Fri, 09 Jan 2015 11:25:57 +0100
To: NETMOD Working Group <netmod@ietf.org>
Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\))
X-Mailer: Apple Mail (2.1993)
X-Virus-Scanned: clamav-milter 0.98.1 at mail
X-Virus-Status: Clean
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/IWuAwpUIPdQusAks-eszE7Vcwbs>
Subject: [netmod] whitespace stripping
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 09 Jan 2015 10:26:01 -0000

Hi,

YANG has this peculiar rule for double-quoted strings:

   If the double-quoted string contains a line break followed by space
   or tab characters that are used to indent the text according to the
   layout in the YANG file, this leading whitespace is stripped from the
   string, up to and including the column of the double quote character,
   or to the first non-whitespace character, whichever occurs first.  In
   this process, a tab character is treated as 8 space characters.

As I recently found out, this kind of whitespace stripping is difficult to implement with some standard parser libraries because the parser has to be able to get the column of the opening double quote. And even if it is possible, it slows down parsing.

The existing practice shows such multi-line strings are only used in descriptions and references where whitespace stripping is not needed at all - e.g., for translation to YIN format such strings have to be re-formatted anyway. In all other cases it is IMO much better to use concatenation

  "..."
+ "..."

So I’d suggest to remove whitespace stripping in YANG 1.1, for the benefit of parsers and the spec itself.

Lada

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C