diff --git a/tests/unit/test_verilog_tokenizer.py b/tests/unit/test_verilog_tokenizer.py index 2ee006699..50e1b6f3c 100644 --- a/tests/unit/test_verilog_tokenizer.py +++ b/tests/unit/test_verilog_tokenizer.py @@ -31,6 +31,18 @@ def test_tokenizes_define(self): ], ) + def test_newline_is_not_whitespace(self): + self.check( + " \n \n\n", + [ + WHITESPACE(value=" "), + NEWLINE(), + WHITESPACE(value=" "), + NEWLINE(), + NEWLINE(), + ], + ) + def test_tokenizes_string_literal(self): self.check('"hello"', [STRING(value="hello")]) diff --git a/vunit/parsing/verilog/tokenizer.py b/vunit/parsing/verilog/tokenizer.py index 74b3cbe31..668a8cec6 100644 --- a/vunit/parsing/verilog/tokenizer.py +++ b/vunit/parsing/verilog/tokenizer.py @@ -67,7 +67,7 @@ def replace_keywords(token): # pylint: disable=missing-docstring add(NEWLINE, r"\n", remove_value) - add(WHITESPACE, r"\s +") + add(WHITESPACE, r"[ \t]+") add( MULTI_COMMENT,