From df9cf0be9b898bc3432d444826ff05d6d0e22f97 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Tue, 7 Jun 2011 04:53:47 -0400 Subject: [PATCH] Add multiline, whitespace-eating strings. --- src/comp/front/lexer.rs | 3 +++ src/test/run-pass/str-multiline.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/test/run-pass/str-multiline.rs diff --git a/src/comp/front/lexer.rs b/src/comp/front/lexer.rs index b6f5ab9e9c3..08409bea14c 100644 --- a/src/comp/front/lexer.rs +++ b/src/comp/front/lexer.rs @@ -632,6 +632,9 @@ fn binop(&reader rdr, token::binop op) -> token::token { case ('"') { str::push_byte(accum_str, '"' as u8); } + case ('\n') { + consume_whitespace(rdr); + } case ('x') { str::push_char(accum_str, diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs new file mode 100644 index 00000000000..c5ad5b15119 --- /dev/null +++ b/src/test/run-pass/str-multiline.rs @@ -0,0 +1,15 @@ +// -*- rust -*- + +use std; +import std::str; + +fn main() { + let str a = "this \ +is a test"; + let str b = "this \ + is \ + another \ + test"; + assert (str::eq(a, "this is a test")); + assert (str::eq(b, "this is another test")); +} \ No newline at end of file