Skip to content

Commit

Permalink
fix(static parser): Allow newlines in expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdeboer committed Dec 5, 2013
1 parent 92a0b01 commit 59a50a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/parser_generator_for_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion lib/tools/parser_generator/source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class SourceBuilder {
Map<String, Code> refs = {};
List<Code> 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) {
Expand Down

0 comments on commit 59a50a0

Please sign in to comment.