- From: Florian Rivoal <florian@rivoal.net>
- Date: Mon, 23 Mar 2015 21:06:43 +0100
- To: Simon Sapin <simon.sapin@exyr.org>
- Cc: www-style list <www-style@w3.org>
> On 23 Mar 2015, at 17:19, Simon Sapin <simon.sapin@exyr.org> wrote: > > The grammar currently is: > >> <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens> >> <media-not> = not <media-in-parens> >> <media-and> = <media-in-parens> [ and <media-in-parens> ]+ >> <media-or> = <media-in-parens> [ or <media-in-parens> ]+ > > When parsing <media-condition>, deciding which of the alternatives should be taken may require looking ahead by an unbounded amount. > > To avoid this, it could be rewritten as: > > <media-condition> = <media-not> > | <media-in-parens> [ <media-and>* | <media-or>* ] > <media-not> = not <media-in-parens> > <media-and> = and <media-in-parens> > <media-or> = or <media-in-parens> > > > Unfortunately that makes more awkward the definitions that follow > >> Each of the major terms of <media-condition> is associated with a >> boolean result, as follows: In an implementation, I agree with you that what you suggest is better. However, in terms of language they accept, the two are equivalent and the current approach makes the spec easier to write as you note. Besides, the intermediate non terminals are not exposed or reused anywhere. Since implementations can do the right thing and implement the more efficient and equivalent grammar you suggest, is there any downside in leaving the spec as it is, for readability reasons? - Florian
Received on Monday, 23 March 2015 20:07:08 UTC