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

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

Issue 8498020: Beginning of CSS parser using frog parsering infrastructure. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor cleanup. Created 9 years 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('css');
6
7 #import('../../frog/lang.dart', prefix:'lang');
8 #import('../../frog/file_system_memory.dart');
9
10 #source('tokenkind.dart');
11 #source('tokenizer.dart');
12 #source('tree.dart');
13 #source('cssselectorexception.dart');
14 #source('cssworld.dart');
15 #source('parser.dart');
16
17
18 void initCssWorld() {
19 var fs = new MemoryFileSystem();
20 lang.parseOptions('', [], fs);
21 lang.initializeWorld(fs);
22 lang.world.process();
23 lang.world.resolveAll();
24
25 // TODO(terry): Should be set by arguments. When run as a tool these aren't
26 // set when run internaly set these so we can compile CSS and catch any
27 // problems programmatically.
28 lang.options.throwOnErrors = true;
29 lang.options.throwOnFatal = true;
30 }
31
32 // TODO(terry): Add obfuscation mapping file.
33 void cssParseAndValidate(String cssExpression, CssWorld world) {
34 Parser parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE,
35 cssExpression));
36 var tree = parser.template();
37 if (tree != null) {
38 parser.validateTemplate(tree.selectors, world);
39 }
40 }
41
42 // Returns pretty printed tree of the expression.
43 String cssParseAndValidateDebug(String cssExpression, CssWorld world) {
44 Parser parser = new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE,
45 cssExpression));
46 String output = "";
47 String prettyTree = "";
48 try {
49 var tree = parser.template();
50 if (tree != null) {
51 prettyTree = tree.toDebugString();
52 parser.validateTemplate(tree.selectors, world);
53 output = prettyTree;
54 }
55 } catch (var e) {
56 String error = e.toString();
57 output = "$error\n$prettyTree";
58 throw e;
59 }
60
61 return output;
62 }
OLDNEW
« no previous file with comments | « frog/source.dart ('k') | utils/css/cssselectorexception.dart » ('j') | utils/css/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698