diff --git a/lib/src/parser.dart b/lib/src/parser.dart index 491c2a67..6acd2cb7 100644 --- a/lib/src/parser.dart +++ b/lib/src/parser.dart @@ -387,8 +387,8 @@ class Parser { if (first == $plus || first == $minus) _scanner.readChar(); num number = 0; - var first = _scanner.peekChar(); - if (!isDigit(first) && first != $dot) _scanner.error("Expected number."); + var second = _scanner.peekChar(); + if (!isDigit(second) && second != $dot) _scanner.error("Expected number."); while (isDigit(_scanner.peekChar())) { number *= 10; @@ -469,7 +469,7 @@ class Parser { } } - return buffer.interpolation(_scanner.spanFrom(start)); + return new StringExpression(buffer.interpolation(_scanner.spanFrom(start))); } Expression _hexColor() => throw new UnimplementedError(); diff --git a/lib/src/visitor/css/serialize.dart b/lib/src/visitor/css/serialize.dart index 6c1c0ef6..2be0c73c 100644 --- a/lib/src/visitor/css/serialize.dart +++ b/lib/src/visitor/css/serialize.dart @@ -6,11 +6,10 @@ import 'package:charcode/charcode.dart'; import '../../ast/css/node.dart'; import '../../util/character.dart'; -import '../../utils.dart'; import '../../value.dart'; import '../css.dart'; -String toCss(AstNode node) { +String toCss(CssNode node) { var visitor = new _SerializeCssVisitor(); node.accept(visitor); var result = visitor._buffer.toString(); @@ -68,10 +67,11 @@ class _SerializeCssVisitor extends CssVisitor { _buffer.writeCharCode($semicolon); } - void visitBoolean(SassBoolean value) => value.value.toString(); + void visitBoolean(SassBoolean value) => + _buffer.write(value.value.toString()); void visitIdentifier(SassIdentifier value) => - value.text.replaceAll("\n", " "); + _buffer.write(value.text.replaceAll("\n", " ")); void visitList(SassList value) { if (value.contents.isEmpty) throw "() isn't a valid CSS value"; @@ -152,13 +152,6 @@ class _SerializeCssVisitor extends CssVisitor { return doubleQuote ? '"$buffer"' : "'$buffer'"; } - num _round(num number) { - if (number is double && (number.isInfinite || number.isNaN)) return number; - if (almostEquals(number % 1, 0.0)) return number.round(); - return (number * 10 * SassNumber.precision).round() / - (10 * SassNumber.precision); - } - void _writeIndentation() { for (var i = 0; i < _indentation; i++) { _buffer.writeCharCode($space); diff --git a/lib/src/visitor/sass/statement/perform.dart b/lib/src/visitor/sass/statement/perform.dart index 5004669f..487215fa 100644 --- a/lib/src/visitor/sass/statement/perform.dart +++ b/lib/src/visitor/sass/statement/perform.dart @@ -43,16 +43,17 @@ class PerformVisitor extends StatementVisitor { void visitDeclaration(Declaration node) { var name = _performInterpolation(node.name); - var value = _performExpression(node.value); + var cssValue = _performExpression(node.value); + var value = cssValue.value; // Don't abort for an empty list because converting it to CSS will throw an // error that we want to user to see. - if (value.value.isBlank && - !(value.value is SassList && value.value.contents.isEmpty)) { + if (value.isBlank && + !(value is SassList && value.contents.isEmpty)) { return; } - _addChild(new CssDeclaration(name, value, span: node.span)); + _addChild(new CssDeclaration(name, cssValue, span: node.span)); } void visitStyleRule(StyleRule node) {