Scripsit Harlan Messinger:
[discussing error reporting for
{font-family: "Book Antiqua", Palatino, "Times New Roman", "Times
Roman" serif} ]
All the validator knew at the point where it reached "serif"--or even
just the "s"--was that it was expecting to see one of the following
but not seeing any of them (not sure this is an exhaustive list): a
comma; !important; a semicolon; or the end of the list.
Actually, "end of the list" doesn't belong here - it's not a syntactic
construct as such.
It can't tell
you "you're missing a comma" because it doesn't know from its point
of view that that's the nature of the problem. Granted, the least it
could do is show you the position of the character where it
identified the presence of a problem.
It _could_ also tell that it was expecting one of ",", "!important ", and
";", as you wrote. But this would probably require a major rewrite of
the program. Moreover, with some extra analysis, it could tell that
indeed a comma is apparently missing, since adding a comma is the
minimal change that makes the construct syntactically correct. Or,
perhaps simpler, since serif is a keyword with a specific meaning, it
cannot start a new declaration or a new rule, so a comma is what is
missing.
If the construct had
"Times Roman" foobar}
then such an analysis would not be possible without lookahead, since
taken locally, the problem might be a missing "}" and foobar might be a
selector, starting a new rule. With lookahead, it might be possible to
judge that this is less like than missing ",".
Advanced error reporting and recovery is possible but it means tedious
work (though this depends on the syntax of the language - CSS is
relatively easy in this respect). Moreover, the risk of issuing very
confusing messages when trying to be helpful is very real. (Been there,
done that.)
In practical terms, a person who checks a stylesheet must be assumed to
know CSS well and to figure out, from good references, where the problem
really is. Automatic checking effectively just tells that _something_ is
wrong and coarsely identifies the location of the problem. Helpful error
messages would be nice, but I can understand that there is little
motivation for working on them.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/