W3C home > Mailing lists > Public > ietf-http-wg@w3.org > April to June 2008

Re: ABNF switch: list rules

From: Zed A. Shaw <zedshaw@zedshaw.com>
Date: Sat, 24 May 2008 03:33:47 -0400
To: HTTP Working Group <ietf-http-wg@w3.org>
Message-Id: <20080524033347.8f75b738.zedshaw@zedshaw.com>

On Fri, 23 May 2008 15:19:09 +0200
Julian Reschke <julian.reschke@gmx.de> wrote:

>    AC-f = ( ( charset | "*" )[ ";" "q" "=" qvalue ] )
>    AC-e = *LWS AC-f
>    COMMA = *LWS ","
> 
>    Accept-Charset = "Accept-Charset" ":" *COMMA AC-e *( COMMA [ AC-e ])

That's actually a common production in programming languages that have
a ; to separate expressions.  They would always have a production that
says something like "a program is a list of expressions separated by ;
and a ; on its own is an empty expression".

The only thing is most parsers and lexers have a way to ignore
whitespace during operation, so they wouldn't need to include the LWS.

Based on that, you could rewrite it like this to be a bit clearer and
potentially reusable for other similar lists:

AC-QValue = ";" "q" "=" qvalue
AC-Type = (charset | "*")
AC-Expression = AC-Type AC-QValue?
AC-Element = *LWS [AC-Expression] [","]
Accept-Charset = "Accept-Charset" ":" *(AC-Element)

Assuming I got the syntax right (didn't refresh my memory about ABNF),
it's effectively saying:

"AC is 'Accept-Charset:' followed by any number of elements.  Elements
have any amount of leading white-space, an optional expression, and an
optional comma.  Expressions have a type and optional q-value."

You should then be able to sprinkle LWS production where they belong.

-- 
Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/
Received on Saturday, 24 May 2008 07:41:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 27 April 2012 06:50:48 GMT