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/