W3C home > Mailing lists > Public > www-style@w3.org > April 1996

Re: Problem with RGB value syntax

From: Bert Bos <Bert.Bos@sophia.inria.fr>
Date: Mon, 22 Apr 1996 22:37:24 +0200
Message-Id: <199604222037.WAA08340@mygale.inria.fr>
To: www-style@www10.w3.org
Chris Lilley writes:
 > Wolfgang Rieger writes:
 >  > There is a problem with the proposed syntax for RGB and RRGGBB values.
 >  > Because both id-selector and RGB values are prefixed with '#', it is
 >  > not possible to use Lex in a straightforward way to implement the
 >  > lexical analyzer.
 > 
 > This is clearly a problem with lex, not with CSS. The selector appears
 > on the lhs and the rgb vales appear on the rhs; there is no ambiguity
 > in the syntax.

Keeping the lex rules simple was not a primary goal. However, Wolfgang
is correct in that the formal grammar is currently incomplete. We have
a corrected draft that is almost finished, which we'll publish as soon
as Hakon is back from the US.

The main point is: what will be easiest to understand for the human
user and I believe that `#' for ID's and `#' for RGB values are both
common practice and not likely to lead to confusion (except among
computer scientists:-) )

The disambiguating rule in the lex spec depends on the `{' and
introduces a `starting condition', like this:

    %s RHS
...
    "{"                     {BEGIN(RHS); return '{';}
...
    "}"                     {BEGIN(INITIAL); return '}';}
...
    <RHS>"#"{h3}            |
    <RHS>"#"{h6}            |
    <RHS>"#"{h9}            {yylval.str = yytext; return HEXCOLOR;}
    "#"                     return '#';

with the appropriate definitions of h3, h6, h9 (hex numbers) and the
token HEXCOLOR. This means that HEXCOLOR can only be matched on the
rhs.




Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/pub/WWW/People/Bos/                      INRIA/W3C
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 93 65 77 71                 06902 Sophia Antipolis Cedex, France
Received on Monday, 22 April 1996 16:37:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:44 GMT