From 489e3d510e3ed9bf4e3388084cc4de6e2749576a Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 19 Feb 2010 17:45:50 -0500 Subject: PR11208: glue adjacent string literals together. * parse.cxx (lexer::scan): Glue adjacent strings together. * testsuite/parseko/twentyseven.stp, semok/thirtyfive.stp: New tests. --- parse.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'parse.cxx') diff --git a/parse.cxx b/parse.cxx index ad4f93f0..f99a440b 100644 --- a/parse.cxx +++ b/parse.cxx @@ -885,6 +885,7 @@ skip: else if (c == '\"') { n->type = tok_string; + another_string: while (1) { c = input_get (); @@ -924,6 +925,19 @@ skip: else n->content.push_back(c); } + // PR11208: check if the next token is also a string literal; auto-concatenate it + // This is complicated to the extent that we need to skip intermediate whitespace. + // XXX: but not comments + unsigned nspace = 0; + do { + c = input_peek(nspace++); + if (c == '\"') // new string literal? + { + // consume all whitespace plus the opening quote + while (nspace-- > 0) input_get(); + goto another_string; // and append the rest to this token + } + } while (isspace(c)); return n; } -- cgit