This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26270 - produce tokens for "/*" and "*/", or define an unclosed comment as a parse error
Summary: produce tokens for "/*" and "*/", or define an unclosed comment as a parse error
Status: RESOLVED FIXED
Alias: None
Product: CSS
Classification: Unclassified
Component: Syntax (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Tab Atkins Jr.
QA Contact: public-css-bugzilla
URL: http://drafts.csswg.org/css-syntax/#c...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-05 10:55 UTC by Michael[tm] Smith
Modified: 2014-07-07 06:31 UTC (History)
0 users

See Also:


Attachments

Description Michael[tm] Smith 2014-07-05 10:55:39 UTC
The CSS Syntax spec should either produce tokens for "/*" and "*/", or define an unclosed comment as a parse error.

For example, I'd like to have the validator produce a message to the user for a case like the following.

  sizes="(max-width: 30em) 100vw, /* comment I forgot to close (max-width: 50em) 50vw, calc(33vw - 100px)"

But the problem is, using a tokenizer conforming to the CSS Syntax spec (or writing one myself), I have no way at all to expose that comment to the validator -- and so, no way to report it to the user.

If a conforming tokenizer produced tokens for "/*" and "*/", I'd be able to expose the lack of a "*/" to the validator and report it to the user. Alternatively, if the "Consume comments" algorithm in the Syntax spec explicitly defined a parse error for the case of an unclosed comment, I wouldn't need the comment tokens -- I could just have the validator code catch that error reported by the tokenizer.

To be clear, I'm not suggesting that any UA behavior around this should change. I'm not proposing that an unclosed comment should be fatal and cause parsing to fail. I'm just suggesting it could be a "parse error" in the particular technical sense in which that term is defined in the spec at http://drafts.csswg.org/css-syntax/#parse-error
Comment 1 L. David Baron (Mozilla) 2014-07-05 14:56:55 UTC
Could it be a tokenization error instead of a parse error?
Comment 2 Michael[tm] Smith 2014-07-05 21:39:01 UTC
(In reply to L. David Baron (Mozilla) from comment #1)
> Could it be a tokenization error instead of a parse error?

Yeah ideally it should be a tokenization error rather than a parse error -- to the degree that the spec actually makes it possible to define tokenization errors separately.

In other words, it should be possible to catch this case just using a conforming tokenizer, without needing a conforming parser.
 
But as far as I can see the current spec doesn't actually define any tokenization errors as such.
Comment 3 Tab Atkins Jr. 2014-07-07 02:48:51 UTC
> Yeah ideally it should be a tokenization error rather than a parse error -- to the degree that the spec actually makes it possible to define tokenization errors separately.

I've gone ahead and flagged it as a parse error.  (It happens during tokenization, but I don't feel like it's important to distinguish in the spec between a term for "errors during tokenization" and "errors during parsing".)

> In other words, it should be possible to catch this case just using a conforming tokenizer, without needing a conforming parser.

Comments disappear during tokenizing anyway; parsing has an allowance for keeping them around, but requires that they be ignored for the purpose of actually running the parser.

> But as far as I can see the current spec doesn't actually define any tokenization errors as such.

Didn't think any were needed (CSS doesn't have very much in the way of error-correction, just error-recovery and auto-closing of things at EOF), but let me know if there's anything obvious I can add that'll make it easier for you.