From 90c9b868b20b11bb089fc5e0c634d5ed76fea0cb Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 4 Jan 2019 10:09:05 -0500 Subject: parser: Fix line continuation outside of (), [] or {} The documentation states: "In other cases you can get multi-line statements by ending the line with a \." but that seems to never have worked. Closes: #4720 --- mesonbuild/mparser.py | 6 +++++- test cases/common/210 line continuation/meson.build | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test cases/common/210 line continuation/meson.build diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index be5c807..fd8052e 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -190,7 +190,11 @@ This will become a hard error in a future Meson release.""", self.getline(line_s line_start = mo.end() - len(lines[-1]) elif tid == 'number': value = int(match_text, base=0) - elif tid == 'eol' or tid == 'eol_cont': + elif tid == 'eol_cont': + lineno += 1 + line_start = loc + break + elif tid == 'eol': lineno += 1 line_start = loc if par_count > 0 or bracket_count > 0 or curl_count > 0: diff --git a/test cases/common/210 line continuation/meson.build b/test cases/common/210 line continuation/meson.build new file mode 100644 index 0000000..16c72f9 --- /dev/null +++ b/test cases/common/210 line continuation/meson.build @@ -0,0 +1,17 @@ +project('line continuation') + +a = 1 +b = 2 + +c = a \ ++b +assert(c == 3, 'Line continuation is not working') + +d = a + \ + b +assert(d == 3, 'Line continuation is not working') + +if a == 1 and \ + b == 3 + error('Line continuation in "if" condition is not working') +endif -- cgit v1.1