Fix parsing qmake assignments that have comments in between
For some reason the python comment regex that we used does not ignore the line break at the end of a comment line. This caused issues when parsing multi line assignments with comments in between. Use our own regex for comments to circumvent the issue. It was found while trying to port the qtimageformats repo. Added a pytest as well. Change-Id: Ie4bbdac2d1e1c133bc787a995224d0bbd8238204 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
parent
14bf7e952e
commit
e0a6e9f3aa
@ -779,7 +779,12 @@ class QmakeParser:
|
||||
expr.setDebug()
|
||||
|
||||
Grammar = StatementGroup('statements')
|
||||
Grammar.ignore(pp.pythonStyleComment())
|
||||
|
||||
# Ignore comment lines, including the final line break,
|
||||
# otherwise parsing fails when looking at multi line assignments
|
||||
# with comments in between.
|
||||
Comment = pp.Regex(r"#.*\n").setName("qmake style comment")
|
||||
Grammar.ignore(Comment())
|
||||
|
||||
return Grammar
|
||||
|
||||
|
4
util/cmake/tests/data/lc_with_comment.pro
Normal file
4
util/cmake/tests/data/lc_with_comment.pro
Normal file
@ -0,0 +1,4 @@
|
||||
SUBDIRS = \
|
||||
# dds \
|
||||
tga \
|
||||
wbmp
|
@ -305,3 +305,7 @@ def test_realworld_lc():
|
||||
result = parse_file(_tests_path + '/data/lc.pro')
|
||||
assert len(result) == 3
|
||||
|
||||
|
||||
def test_realworld_lc_with_comment_in_between():
|
||||
result = parse_file(_tests_path + '/data/lc_with_comment.pro')
|
||||
assert len(result) == 1
|
||||
|
Loading…
Reference in New Issue
Block a user