diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-02-27 13:58:00 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-02-28 08:08:08 +0000 |
commit | 754ba287999e0d1681f77d12f6d7c3ae0362745a (patch) | |
tree | c8d834725da22f4165ec96bacf1495a46aa53612 | |
parent | 8512f5179d2674dd9c0b89eeebbf2c6d32e3e4b4 (diff) |
CMake: pro2cmake.py: Fix parsing of Line continuation before end of file
... and add a test case for this.
Change-Id: If20d737b54ecb3f9e128e59070b238c840acad6c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rwxr-xr-x | util/cmake/pro2cmake.py | 2 | ||||
-rw-r--r-- | util/cmake/tests/data/sql.pro | 3 | ||||
-rwxr-xr-x | util/cmake/tests/test_parsing.py | 6 |
3 files changed, 10 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 6002f78037..5d161a139a 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -518,7 +518,7 @@ class QmakeParser: pp.ParserElement.setDefaultWhitespaceChars(' \t') LC = pp.Suppress(pp.Literal('\\\n')) - EOL = pp.Suppress(pp.Literal('\n')) + EOL = pp.Suppress(pp.Literal('\n') ^ pp.LineEnd()) Else = pp.Keyword('else') Identifier = pp.Word(pp.alphas + '_', bodyChars=pp.alphanums+'_-./') BracedValue = pp.nestedExpr(ignoreExpr=pp.quotedString \ diff --git a/util/cmake/tests/data/sql.pro b/util/cmake/tests/data/sql.pro new file mode 100644 index 0000000000..a9d7fc7c5a --- /dev/null +++ b/util/cmake/tests/data/sql.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + kernel \ diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py index d0a9960dc7..1f50fc87ab 100755 --- a/util/cmake/tests/test_parsing.py +++ b/util/cmake/tests/test_parsing.py @@ -281,3 +281,9 @@ def test_realworld_complex_condition(): assert len(else_branch) == 0 + +def test_realworld_sql(): + result = parse_file(_tests_path + '/data/sql.pro') + assert len(result) == 2 + validate_op('TEMPLATE', '=', ['subdirs'], result[0]) + validate_op('SUBDIRS', '=', ['kernel'], result[1]) |