From 37b702e9aa4255e1d0c5fa706e52842877cf01b3 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Sun, 18 Feb 2018 17:18:51 -0800 Subject: Fail if singleline string has multiple lines --- mesonbuild/mparser.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/mparser.py') diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 94d56e5..2db3375 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -141,6 +141,9 @@ class Lexer: elif tid == 'dblquote': raise ParseException('Double quotes are not supported. Use single quotes.', self.getline(line_start), lineno, col) elif tid == 'string': + # Handle here and not on the regexp to give a better error message. + if match_text.find("\n") != -1: + raise ParseException("Use ''' (three single quotes) for multiline strings.", self.getline(line_start), lineno, col) value = match_text[1:-1].replace(r"\'", "'") value = newline_rx.sub(r'\1\n', value) value = value.replace(r" \\ ".strip(), r" \ ".strip()) -- cgit v1.1