Skip to content
Snippets Groups Projects
Commit d3820174 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Fixed line number counter in parser for comments

parent 90e4a60f
No related branches found
No related tags found
No related merge requests found
......@@ -35,11 +35,14 @@ def parse_groups(css):
for c in css:
char = c
if char == '\n':
lineno += 1
if comment:
# Comment end?
if c == '/' and prev_char == '*':
if char == '/' and prev_char == '*':
comment = False
elif c == '{':
elif char == '{':
# Block start
if selectors is not None:
# Block is nested, save group selector
......@@ -50,7 +53,7 @@ def parse_groups(css):
#print stack.strip(), '->', selectors
stack = ''
assert len(selectors)
elif c == '}':
elif char == '}':
# Last property may not have been closed with a semicolon
parse_property()
......@@ -62,21 +65,18 @@ def parse_groups(css):
current_group.append((selectors, properties))
selectors = None
properties = []
elif c == ';':
elif char == ';':
# Property definition
parse_property()
stack = ''
elif c == '*' and prev_char == '/':
elif char == '*' and prev_char == '/':
# Comment start
comment = True
stack = stack[:-1]
else:
if c == '\n':
lineno += 1
stack += c
stack += char
prev_char = c
prev_char = char
except AssertionError:
raise Exception('unexpected \'%c\' on line %d' % (char, lineno))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment