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

Side by Side Diff: example/call_parser.dart

Issue 1022963002: pkg/csslib: fixes for args (Closed) Base URL: https://github.com/dart-lang/csslib@master
Patch Set: another idea Created 5 years, 8 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
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 3
4 import 'package:csslib/parser.dart' as css; 4 import 'package:csslib/parser.dart' as css;
5 import 'package:csslib/visitor.dart'; 5 import 'package:csslib/visitor.dart';
6 6
7 const _default = const css.PreprocessorOptions(
8 useColors: false,
9 checked: true,
10 warningsAsErrors: true,
11 inputFile: 'memory');
12
7 /** 13 /**
8 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, 14 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
9 * CSS will allow any property/value pairs regardless of validity; all of our 15 * CSS will allow any property/value pairs regardless of validity; all of our
10 * tests (by default) will ensure that the CSS is really valid. 16 * tests (by default) will ensure that the CSS is really valid.
11 */ 17 */
12 StyleSheet parseCss(String cssInput, {List errors, List opts}) => css.parse( 18 StyleSheet parseCss(String cssInput,
13 cssInput, 19 {List errors, css.PreprocessorOptions opts}) => css.parse(cssInput,
Bob Nystrom 2015/04/03 16:15:24 This method is long enough that it should really u
kevmoo 2015/04/03 16:31:25 Done.
14 errors: errors, 20 errors: errors, options: opts == null ? _default : opts);
15 options: opts == null
16 ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory']
17 : opts);
18 21
19 // Pretty printer for CSS. 22 // Pretty printer for CSS.
20 var emitCss = new CssPrinter(); 23 var emitCss = new CssPrinter();
21 String prettyPrint(StyleSheet ss) => 24 String prettyPrint(StyleSheet ss) =>
22 (emitCss..visitTree(ss, pretty: true)).toString(); 25 (emitCss..visitTree(ss, pretty: true)).toString();
23 26
24 main() { 27 main() {
25 var errors = []; 28 var errors = [];
26 29
27 // Parse a simple stylesheet. 30 // Parse a simple stylesheet.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 var selectorAst = css.selector('#div .foo', errors: errors); 85 var selectorAst = css.selector('#div .foo', errors: errors);
83 if (!errors.isEmpty) { 86 if (!errors.isEmpty) {
84 print("Got ${errors.length} errors.\n"); 87 print("Got ${errors.length} errors.\n");
85 for (var error in errors) { 88 for (var error in errors) {
86 print(error); 89 print(error);
87 } 90 }
88 } else { 91 } else {
89 print(prettyPrint(selectorAst)); 92 print(prettyPrint(selectorAst));
90 } 93 }
91 } 94 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/parser.dart » ('j') | lib/src/messages.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698