Subject: [netmod] Single/double quote as an unquoted string

From: Jernej Tuljak <[email-masked]>
Date: Mon, 21 Oct 2013 16:25:47 +0200

Section 6.1.3 Quoting, RFC6020, states the following:

    If a string contains any space or tab characters, a semicolon (";"),
    braces ("{" or "}"), or comment sequences ("//", "/*", or "*/"), then
    it MUST be enclosed within double or single quotes.

Shouldn't this also include single quote (') and double quote (")? As it 
is now, this is allowed:

    default "; // or '

The thing is..how's a lexer supposed to differentiate between quoted and 
unquoted strings (for YANG concatenation) if this is allowed? Consider:

    default ";
    units ";

Is this (A) a single default statement with an argument of ";\n units " 
or (B) are there two YANG keywords with a double quote as an argument? 
There's nothing that prohibits using a semicolon/newline/whitespace 
inside quoted strings, so the first case is perfectly valid. There's 
also nothing that prohibits an unquoted string with a value of a single 
or a double quote. So which one is it?

Jernej

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Mon, 21 Oct 2013 16:40:32 +0200

On Mon, Oct 21, 2013 at 04:25:47PM +0200, Jernej Tuljak wrote:
> Shouldn't this also include single quote (') and double quote (")?
> As it is now, this is allowed:
> 
>    default "; // or '
> 
> The thing is..how's a lexer supposed to differentiate between quoted
> and unquoted strings (for YANG concatenation) if this is allowed?
> Consider:
> 
>    default ";
>    units ";
> 
> Is this (A) a single default statement with an argument of ";\n
> units " or (B) are there two YANG keywords with a double quote as an
> argument? There's nothing that prohibits using a
> semicolon/newline/whitespace inside quoted strings, so the first
> case is perfectly valid. There's also nothing that prohibits an
> unquoted string with a value of a single or a double quote. So which
> one is it?

A double quote always starts or ends a quoted strings unless it is
prefixed with a backslash or it is enclosed in a single quoted string.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

---

From: Andy Bierman <[email-masked]>
Date: Mon, 21 Oct 2013 07:47:26 -0700

Hi,

sec. 6.1.3 is not precise enough.
Quoted strings must end end the char that started the string.
Double quoted strings are also treated special wrt/ formatting
and special chars within the string. The RFC is not clear about
reformatting combined strings:

  "\n    foo" + '\nbar'  + "\n   baz".

Is it A, B, or C?

A)

   foo
bar
   baz

B)

   foo
   bar
   baz

C)

   foo\nbar
   baz

Implementing string concatenation with mixed strings is also problematic.
The result can contain chars that are not allowed in either quoting
format so rendering the combined strings with quotes is not possible.

> Shouldn't this also include single quote (') and double quote (")? As it
A double quote has to end the string.
The RFC should make this clear.

> unquoted strings (for YANG concatenation) if this is allowed? Consider:
Is this (A) a single default statement with an argument of ";\n units " or
> (B) are there two YANG keywords with a double quote as an argument? There's
> nothing that prohibits using a semicolon/newline/whitespace inside quoted
> strings, so the first case is perfectly valid. There's also nothing that
> prohibits an unquoted string with a value of a single or a double quote. So
> which one is it?
>

This is just 1 default-stmt (if both quotes are double-quotes).

> Jernej

Andy

---

From: Jernej Tuljak <[email-masked]>
Date: Mon, 21 Oct 2013 16:51:49 +0200

It's C. Single quotes preserve all characters.

Jernej
 Dne 21. okt. 2013 16:47 je oseba "Andy Bierman" <[email-masked]>
napisala:

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
>
>

---

From: Andy Bierman <[email-masked]>
Date: Mon, 21 Oct 2013 07:54:45 -0700

Hi,

...

   default "; // or '

It should be clear from the RFC that a comment within a quoted string
is not treated at a comment at all. The quoted string starts a token.
Everything up to the closing quote is part of that 1 token.

Andy

---

From: Andy Bierman <[email-masked]>
Date: Mon, 21 Oct 2013 07:56:30 -0700

> It's C. Single quotes preserve all characters.

I agree.

Andy

>>> There's nothing that prohibits using a semicolon/newline/whitespace inside
>>> quoted strings, so the first case is perfectly valid. There's also nothing
>>> that prohibits an unquoted string with a value of a single or a double
>>> quote. So which one is it?
>>>
>>

---

From: Jernej Tuljak <[email-masked]>
Date: Tue, 22 Oct 2013 10:25:13 +0200

> prefixed with a backslash or it is enclosed in a single quoted string.

You meant "...unless it is prefixed with a backslash within a double 
quoted string...", right?

Jernej