Fail if singleline string has multiple lines

pull/3103/head
Caio Marcelo de Oliveira Filho 7 years ago committed by Jussi Pakkanen
parent aeee01f639
commit 37b702e9aa
  1. 3
      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())

Loading…
Cancel
Save