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

Unified Diff: frog/css/csstemplate.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: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: frog/css/csstemplate.dart
diff --git a/frog/css/csstemplate.dart b/frog/css/csstemplate.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0aebea93075fdba60b892f3b3d0a3025a9c9a8c6
--- /dev/null
+++ b/frog/css/csstemplate.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#import('css.dart');
+
+class CssTemplate {
+ // TODO(terry): Add obfuscation mapping file.
+ static void xlate(String cssExpression, CssWorld world) {
jimhug 2011/11/09 16:04:03 Speaking for Bob <smile>. Any reason not to just
terry 2011/11/09 21:56:06 Good point Bob (Jim?) I'll do that. Done.
+ Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE,
+ cssExpression));
+ try {
+ var tree = parser.template(true);
+ if (tree != null) {
+ parser.validateTemplate(tree.selectors, world);
+ }
+ } catch (var cssException) {
+ print(cssException.toString());
+ throw cssException;
+ }
+ }
+
+ // Returns pretty printed tree of the expression.
+ static String xlateDebug(String cssExpression, CssWorld world) {
+ Parser parser = new Parser(new SourceFile(SourceFile.IN_MEMORY_FILE,
+ cssExpression));
+ String output = "";
+ String prettyTree = "";
+ try {
+ var tree = parser.template(true);
+ if (tree != null) {
+ prettyTree = tree.toDebugString();
+ parser.validateTemplate(tree.selectors, world);
+ output = prettyTree;
+ }
+ } catch (var cssException) {
+ String error = cssException.toString();
+ output = "$error\n$prettyTree";
+ throw cssException;
+ }
+
+ return output;
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698