Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: pkg/csslib/lib/parser.dart

Issue 126063003: Fixed single quote escaping (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/csslib/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library csslib.parser; 5 library csslib.parser;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import 'package:source_maps/span.dart' show SourceFile, Span, FileSpan; 9 import 'package:source_maps/span.dart' show SourceFile, Span, FileSpan;
10 10
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 break; 1487 break;
1488 case TokenKind.INTEGER: 1488 case TokenKind.INTEGER:
1489 termToken = _next(); 1489 termToken = _next();
1490 value = int.parse(termToken.text); 1490 value = int.parse(termToken.text);
1491 break; 1491 break;
1492 case TokenKind.DOUBLE: 1492 case TokenKind.DOUBLE:
1493 termToken = _next(); 1493 termToken = _next();
1494 value = double.parse(termToken.text); 1494 value = double.parse(termToken.text);
1495 break; 1495 break;
1496 case TokenKind.SINGLE_QUOTE: 1496 case TokenKind.SINGLE_QUOTE:
1497 value = processQuotedString(false);
1498 value = "'${_escapeString(value, single: true)}'";
1499 return new LiteralTerm(value, value, _makeSpan(start));
1497 case TokenKind.DOUBLE_QUOTE: 1500 case TokenKind.DOUBLE_QUOTE:
1498 value = processQuotedString(false); 1501 value = processQuotedString(false);
1499 value = '"${_escapeString(value)}"'; 1502 value = '"${_escapeString(value)}"';
1500 return new LiteralTerm(value, value, _makeSpan(start)); 1503 return new LiteralTerm(value, value, _makeSpan(start));
1501 case TokenKind.IDENTIFIER: 1504 case TokenKind.IDENTIFIER:
1502 value = identifier(); // Snarf up the ident we'll remap, maybe. 1505 value = identifier(); // Snarf up the ident we'll remap, maybe.
1503 break; 1506 break;
1504 default: 1507 default:
1505 keepParsing = false; 1508 keepParsing = false;
1506 } 1509 }
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 return _parseHex(" ${processTerm().text}", _makeSpan(start)); 2125 return _parseHex(" ${processTerm().text}", _makeSpan(start));
2123 case TokenKind.INTEGER: 2126 case TokenKind.INTEGER:
2124 t = _next(); 2127 t = _next();
2125 value = int.parse("${unary}${t.text}"); 2128 value = int.parse("${unary}${t.text}");
2126 break; 2129 break;
2127 case TokenKind.DOUBLE: 2130 case TokenKind.DOUBLE:
2128 t = _next(); 2131 t = _next();
2129 value = double.parse("${unary}${t.text}"); 2132 value = double.parse("${unary}${t.text}");
2130 break; 2133 break;
2131 case TokenKind.SINGLE_QUOTE: 2134 case TokenKind.SINGLE_QUOTE:
2135 value = processQuotedString(false);
2136 value = "'${_escapeString(value, single: true)}'";
2137 return new LiteralTerm(value, value, _makeSpan(start));
2132 case TokenKind.DOUBLE_QUOTE: 2138 case TokenKind.DOUBLE_QUOTE:
2133 value = processQuotedString(false); 2139 value = processQuotedString(false);
2134 value = '"${_escapeString(value)}"'; 2140 value = '"${_escapeString(value)}"';
2135 return new LiteralTerm(value, value, _makeSpan(start)); 2141 return new LiteralTerm(value, value, _makeSpan(start));
2136 case TokenKind.LPAREN: 2142 case TokenKind.LPAREN:
2137 _next(); 2143 _next();
2138 2144
2139 GroupTerm group = new GroupTerm(_makeSpan(start)); 2145 GroupTerm group = new GroupTerm(_makeSpan(start));
2140 2146
2141 var term; 2147 var term;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 2664
2659 if (replace != null && result == null) { 2665 if (replace != null && result == null) {
2660 result = new StringBuffer(text.substring(0, i)); 2666 result = new StringBuffer(text.substring(0, i));
2661 } 2667 }
2662 2668
2663 if (result != null) result.write(replace != null ? replace : text[i]); 2669 if (result != null) result.write(replace != null ? replace : text[i]);
2664 } 2670 }
2665 2671
2666 return result == null ? text : result.toString(); 2672 return result == null ? text : result.toString();
2667 } 2673 }
OLDNEW
« no previous file with comments | « no previous file | pkg/csslib/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698