From 59a50a07572d2f8783e9d3e5f07e2881e8c53955 Mon Sep 17 00:00:00 2001 From: James deBoer Date: Tue, 26 Nov 2013 08:18:38 -0800 Subject: [PATCH] fix(static parser): Allow newlines in expressions. Closes #297 --- bin/parser_generator_for_spec.dart | 1 + lib/tools/parser_generator/source.dart | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/parser_generator_for_spec.dart b/bin/parser_generator_for_spec.dart index 0a9744dbc..59e3e555d 100644 --- a/bin/parser_generator_for_spec.dart +++ b/bin/parser_generator_for_spec.dart @@ -18,6 +18,7 @@ main(arguments) { // List generated using: // node node_modules/karma/bin/karma run | grep -Eo ":XNAY:.*:XNAY:" | sed -e 's/:XNAY://g' | sed -e "s/^/'/" | sed -e "s/$/',/" | sort | uniq > missing_expressions injector.get(isGetter ? ParserGetterSetter : ParserGenerator).generateParser([ + "foo == 'bar' ||\nbaz" "null", "[1, 2].length", "doesNotExist", diff --git a/lib/tools/parser_generator/source.dart b/lib/tools/parser_generator/source.dart index 70a7b4222..d2f5b97ed 100644 --- a/lib/tools/parser_generator/source.dart +++ b/lib/tools/parser_generator/source.dart @@ -8,7 +8,10 @@ class SourceBuilder { Map refs = {}; List codeRefs = []; - String str(String s) => '\'' + s.replaceAll('\'', '\\\'').replaceAll(r'$', r'\$') + '\''; + String str(String s) => '\'' + + s.replaceAll('\'', '\\\'') + .replaceAll('\n', '\\n') + .replaceAll(r'$', r'\$') + '\''; String ident(String s) => '_${s.replaceAll(NON_WORDS, '_')}_${s.hashCode}'; String ref(Code code) {