Add an executable and fix some bugs.

This commit is contained in:
Natalie Weizenbaum 2016-05-23 18:11:09 -07:00
parent e2befee5d8
commit 2f332b4bbc
3 changed files with 23 additions and 4 deletions

14
bin/sass.dart Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2016 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:sass/src/parser.dart';
void main(List<String> args) {
var parser = new Parser(new File(args.first).readAsStringSync(),
url: p.toUri(args.first));
print(parser.parse());
}

View File

@ -22,8 +22,8 @@ class Parser {
// Conventions:
//
// * All statement and expression functions consume through following
// whitespace, including comments.
// * All statement functions consume through following whitespace, including
// comments. No other functions do so unless explicitly specified.
//
// * A function will return `null` if it fails to match iff it begins with
// "try".
@ -78,9 +78,9 @@ class Parser {
guarded: guarded, global: global, span: _scanner.spanFrom(start));
}
AstNode _tryAtRule() => throw new UnimplementedError();
AstNode _tryAtRule() => null;
AstNode _tryDeclaration() => throw new UnimplementedError();
AstNode _tryDeclaration() => null;
/// Consumes whitespace if available and returns any comments it contained.
List<CommentNode> _comments() {
@ -122,6 +122,7 @@ class Parser {
var next = _trySingleExpression();
if (next == null) break;
spaceExpressions.add(next);
_ignoreComments();
}
if (spaceExpressions.isEmpty) {
@ -177,6 +178,8 @@ class Parser {
return _unaryOperator();
default:
if (first == null) return null;
if (_isNameStart(first) || first == $backslash) {
return _identifierLike();
}
@ -237,6 +240,7 @@ class Parser {
}
}
if (!text.isEmpty) contents.add(text.toString());
return new InterpolationExpression(
contents, span: _scanner.spanFrom(start));
}

View File

@ -9,6 +9,7 @@ environment:
dependencies:
charcode: "^1.1.0"
path: "^1.0.0"
source_span: "^1.0.0"
string_scanner: "^0.1.4"