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