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

Side by Side Diff: utils/css/css.dart

Issue 9695048: Template parser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix GIT mixup - ugh Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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('css'); 5 #library('css');
6 6
7 #import('../../frog/lang.dart', prefix:'lang');
8 #import('../../frog/file_system.dart'); 7 #import('../../frog/file_system.dart');
9 #import('../../frog/file_system_memory.dart'); 8 #import('../../frog/file_system_memory.dart');
9 #source('cssoptions.dart');
10 #source('source.dart');
10 #source('tokenkind.dart'); 11 #source('tokenkind.dart');
12 #source('token.dart');
13 #source('tokenizer_base.dart');
11 #source('tokenizer.dart'); 14 #source('tokenizer.dart');
15 #source('treebase.dart');
12 #source('tree.dart'); 16 #source('tree.dart');
13 #source('cssselectorexception.dart'); 17 #source('cssselectorexception.dart');
14 #source('cssworld.dart'); 18 #source('cssworld.dart');
15 #source('parser.dart'); 19 #source('parser.dart');
16 #source('validate.dart'); 20 #source('validate.dart');
17 #source('generate.dart'); 21 #source('generate.dart');
22 #source('world.dart');
18 23
19 24
20 void initCssWorld([bool commandLine = true]) { 25 void initCssWorld([bool commandLine = true]) {
21 var fs = new MemoryFileSystem(); 26 var fs = new MemoryFileSystem();
22 lang.parseOptions('', [], fs); 27 parseOptions([], fs);
23 lang.initializeWorld(fs); 28 initializeWorld(fs);
24 lang.world.process();
25 lang.world.resolveAll();
26 29
27 // TODO(terry): Should be set by arguments. When run as a tool these aren't 30 // TODO(terry): Should be set by arguments. When run as a tool these aren't
28 // set when run internaly set these so we can compile CSS and catch any 31 // set when run internaly set these so we can compile CSS and catch any
29 // problems programmatically. 32 // problems programmatically.
30 lang.options.throwOnErrors = true; 33 options.throwOnErrors = true;
31 lang.options.throwOnFatal = true; 34 options.throwOnFatal = true;
32 lang.options.useColors = commandLine ? true : false; 35 options.useColors = commandLine ? true : false;
36 options.warningsAsErrors = false;
37 options.showWarnings = true;
33 } 38 }
34 39
35 // TODO(terry): Add obfuscation mapping file. 40 // TODO(terry): Add obfuscation mapping file.
36 void cssParseAndValidate(String cssExpression, CssWorld world) { 41 void cssParseAndValidate(String cssExpression, CssWorld cssworld) {
37 Parser parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, 42 Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE,
38 cssExpression)); 43 cssExpression));
39 var tree = parser.parseTemplate(); 44 var tree = parser.parseTemplate();
40 if (tree != null) { 45 if (tree != null) {
41 Validate.template(tree.selectors, world); 46 Validate.template(tree.selectors, cssworld);
42 } 47 }
43 } 48 }
44 49
45 // Returns pretty printed tree of the expression. 50 // Returns pretty printed tree of the expression.
46 String cssParseAndValidateDebug(String cssExpression, CssWorld world) { 51 String cssParseAndValidateDebug(String cssExpression, CssWorld cssworld) {
47 Parser parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, 52 Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE,
48 cssExpression)); 53 cssExpression));
49 String output = ""; 54 String output = "";
50 String prettyTree = ""; 55 String prettyTree = "";
51 try { 56 try {
52 var tree = parser.parseTemplate(); 57 var tree = parser.parseTemplate();
53 if (tree != null) { 58 if (tree != null) {
54 prettyTree = tree.toDebugString(); 59 prettyTree = tree.toDebugString();
55 Validate.template(tree.selectors, world); 60 Validate.template(tree.selectors, cssworld);
56 output = prettyTree; 61 output = prettyTree;
57 } 62 }
58 } catch (var e) { 63 } catch (var e) {
59 String error = e.toString(); 64 String error = e.toString();
60 output = "$error\n$prettyTree"; 65 output = "$error\n$prettyTree";
61 throw e; 66 throw e;
62 } 67 }
63 68
64 return output; 69 return output;
65 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698