css parser: Show line numbers for errors.

This is a fairly major overhaul of the CSS parser to support
line numbers in error messages.

Basically, instead of passing "slices" of tokens around, we pass
indexes into the token arrays to all of our sub-parsers, which
allows them to have access to previous tokens in certain cases.
This is particularly important for errors where stuff is missing
(vs. being wrong).

In testing this out I found a few more places to catch errors.
This commit is contained in:
Steve Howell
2017-02-01 06:31:24 -08:00
committed by Tim Abbott
parent a03d816983
commit 2a07b204bf
3 changed files with 113 additions and 89 deletions

View File

@@ -193,6 +193,16 @@ class ParserTestSadPath(unittest.TestCase):
error = 'Missing selector'
self._assert_error(my_css, error)
def test_missing_value(self):
# type: () -> None
my_css = '''
h1
{
bottom:
}'''
error = 'Missing value'
self._assert_error(my_css, error)
def test_disallow_comments_in_selectors(self):
# type: () -> None
my_css = '''