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

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: nits 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
« no previous file with comments | « CHANGELOG.md ('k') | lib/parser.dart » ('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 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}) {
14 errors: errors, 20 return css.parse(cssInput,
15 options: opts == null 21 errors: errors, options: opts == null ? _default : opts);
16 ? ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] 22 }
17 : opts);
18 23
19 // Pretty printer for CSS. 24 // Pretty printer for CSS.
20 var emitCss = new CssPrinter(); 25 var emitCss = new CssPrinter();
21 String prettyPrint(StyleSheet ss) => 26 String prettyPrint(StyleSheet ss) =>
22 (emitCss..visitTree(ss, pretty: true)).toString(); 27 (emitCss..visitTree(ss, pretty: true)).toString();
23 28
24 main() { 29 main() {
25 var errors = []; 30 var errors = [];
26 31
27 // Parse a simple stylesheet. 32 // 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); 87 var selectorAst = css.selector('#div .foo', errors: errors);
83 if (!errors.isEmpty) { 88 if (!errors.isEmpty) {
84 print("Got ${errors.length} errors.\n"); 89 print("Got ${errors.length} errors.\n");
85 for (var error in errors) { 90 for (var error in errors) {
86 print(error); 91 print(error);
87 } 92 }
88 } else { 93 } else {
89 print(prettyPrint(selectorAst)); 94 print(prettyPrint(selectorAst));
90 } 95 }
91 } 96 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698