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

Unified Diff: pkg/polymer_expressions/lib/visitor.dart

Issue 22950008: move fancy_syntax into Dart SVN (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer_expressions/lib/tokenizer.dart ('k') | pkg/polymer_expressions/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer_expressions/lib/visitor.dart
diff --git a/pkg/polymer_expressions/lib/visitor.dart b/pkg/polymer_expressions/lib/visitor.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a11a0d4c0933395273543d84e71fe6758f88631a
--- /dev/null
+++ b/pkg/polymer_expressions/lib/visitor.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2013, 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.
+
+library polymer_expressions.visitor;
+
+import 'expression.dart';
+
+abstract class Visitor<E extends Expression> {
+ visit(E s) => s.accept(this);
+ visitEmptyExpression(EmptyExpression e);
+ visitParenthesizedExpression(ParenthesizedExpression e);
+ visitInvoke(Invoke i);
+ visitLiteral(Literal l);
+ visitMapLiteral(MapLiteral l);
+ visitMapLiteralEntry(MapLiteralEntry l);
+ visitIdentifier(Identifier i);
+ visitBinaryOperator(BinaryOperator o);
+ visitUnaryOperator(UnaryOperator o);
+ visitInExpression(InExpression c);
+}
+
+abstract class RecursiveVisitor<E> extends Visitor<E> {
+ visitExpression(E e);
+
+ visitEmptyExpression(EmptyExpression e) => visitExpression(e);
+
+ visitParenthesizedExpression(ParenthesizedExpression e) {
+ visit(e);
+ visitExpression(e);
+ }
+
+ visitInvoke(Invoke i) {
+ visit(i.receiver);
+ if (i.arguments != null) {
+ for (var a in i.arguments) {
+ visit(a);
+ }
+ }
+ visitExpression(i);
+ }
+
+ visitLiteral(Literal l) => visitExpression(l);
+
+ visitMapLiteral(MapLiteral l) {
+ for (var e in l.entries) {
+ visit(e);
+ }
+ visitExpression(l);
+ }
+
+ visitMapLiteralEntry(MapLiteralEntry e) {
+ visit(e.key);
+ visit(e.entryValue);
+ visitExpression(e);
+ }
+
+ visitIdentifier(Identifier i) => visitExpression(i);
+
+ visitBinaryOperator(BinaryOperator o) {
+ visit(o.left);
+ visit(o.right);
+ visitExpression(o);
+ }
+
+ visitUnaryOperator(UnaryOperator o) {
+ visit(o.child);
+ visitExpression(o);
+ }
+
+ visitInExpression(InExpression c) {
+ visit(c.left);
+ visit(c.right);
+ visitExpression(c);
+ }
+}
« no previous file with comments | « pkg/polymer_expressions/lib/tokenizer.dart ('k') | pkg/polymer_expressions/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698