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

Side by Side Diff: dart/lib/compiler/implementation/tree/nodes.dart

Issue 11027023: Parse/unparse library combinators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 abstract class Visitor<R> { 5 abstract class Visitor<R> {
6 const Visitor(); 6 const Visitor();
7 7
8 abstract R visitNode(Node node); 8 abstract R visitNode(Node node);
9 9
10 R visitBlock(Block node) => visitStatement(node); 10 R visitBlock(Block node) => visitStatement(node);
11 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); 11 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node);
12 R visitCascade(Cascade node) => visitExpression(node); 12 R visitCascade(Cascade node) => visitExpression(node);
13 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node); 13 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node);
14 R visitCaseMatch(CaseMatch node) => visitNode(node); 14 R visitCaseMatch(CaseMatch node) => visitNode(node);
15 R visitCatchBlock(CatchBlock node) => visitNode(node); 15 R visitCatchBlock(CatchBlock node) => visitNode(node);
16 R visitClassNode(ClassNode node) => visitNode(node); 16 R visitClassNode(ClassNode node) => visitNode(node);
17 R visitCombinator(Combinator node) => visitNode(node);
17 R visitConditional(Conditional node) => visitExpression(node); 18 R visitConditional(Conditional node) => visitExpression(node);
18 R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node); 19 R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node);
19 R visitDoWhile(DoWhile node) => visitLoop(node); 20 R visitDoWhile(DoWhile node) => visitLoop(node);
20 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); 21 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
21 R visitExport(Export node) => visitNode(node); 22 R visitExport(Export node) => visitLibraryTag(node);
22 R visitExpression(Expression node) => visitNode(node); 23 R visitExpression(Expression node) => visitNode(node);
23 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); 24 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
24 R visitFor(For node) => visitLoop(node); 25 R visitFor(For node) => visitLoop(node);
25 R visitForIn(ForIn node) => visitLoop(node); 26 R visitForIn(ForIn node) => visitLoop(node);
26 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node); 27 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node);
27 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); 28 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
28 R visitGotoStatement(GotoStatement node) => visitStatement(node); 29 R visitGotoStatement(GotoStatement node) => visitStatement(node);
29 R visitIdentifier(Identifier node) => visitExpression(node); 30 R visitIdentifier(Identifier node) => visitExpression(node);
30 R visitIf(If node) => visitStatement(node); 31 R visitIf(If node) => visitStatement(node);
31 R visitImport(Import node) => visitNode(node); 32 R visitImport(Import node) => visitLibraryTag(node);
32 R visitLabel(Label node) => visitNode(node); 33 R visitLabel(Label node) => visitNode(node);
33 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); 34 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
34 R visitLibraryName(LibraryName node) => visitNode(node); 35 R visitLibraryName(LibraryName node) => visitLibraryTag(node);
36 R visitLibraryTag(LibraryTag node) => visitNode(node);
35 R visitLiteral(Literal node) => visitExpression(node); 37 R visitLiteral(Literal node) => visitExpression(node);
36 R visitLiteralBool(LiteralBool node) => visitLiteral(node); 38 R visitLiteralBool(LiteralBool node) => visitLiteral(node);
37 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); 39 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node);
38 R visitLiteralInt(LiteralInt node) => visitLiteral(node); 40 R visitLiteralInt(LiteralInt node) => visitLiteral(node);
39 R visitLiteralList(LiteralList node) => visitExpression(node); 41 R visitLiteralList(LiteralList node) => visitExpression(node);
40 R visitLiteralMap(LiteralMap node) => visitExpression(node); 42 R visitLiteralMap(LiteralMap node) => visitExpression(node);
41 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node); 43 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node);
42 R visitLiteralNull(LiteralNull node) => visitLiteral(node); 44 R visitLiteralNull(LiteralNull node) => visitLiteral(node);
43 R visitLiteralString(LiteralString node) => visitStringNode(node); 45 R visitLiteralString(LiteralString node) => visitStringNode(node);
44 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node); 46 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node);
45 R visitLoop(Loop node) => visitStatement(node); 47 R visitLoop(Loop node) => visitStatement(node);
46 R visitModifiers(Modifiers node) => visitNode(node); 48 R visitModifiers(Modifiers node) => visitNode(node);
47 R visitNamedArgument(NamedArgument node) => visitExpression(node); 49 R visitNamedArgument(NamedArgument node) => visitExpression(node);
48 R visitNewExpression(NewExpression node) => visitExpression(node); 50 R visitNewExpression(NewExpression node) => visitExpression(node);
49 R visitNodeList(NodeList node) => visitNode(node); 51 R visitNodeList(NodeList node) => visitNode(node);
50 R visitOperator(Operator node) => visitIdentifier(node); 52 R visitOperator(Operator node) => visitIdentifier(node);
51 R visitParenthesizedExpression(ParenthesizedExpression node) { 53 R visitParenthesizedExpression(ParenthesizedExpression node) {
52 return visitExpression(node); 54 return visitExpression(node);
53 } 55 }
54 R visitPart(Part node) => visitNode(node); 56 R visitPart(Part node) => visitLibraryTag(node);
55 R visitPartOf(PartOf node) => visitNode(node); 57 R visitPartOf(PartOf node) => visitLibraryTag(node);
56 R visitPostfix(Postfix node) => visitNodeList(node); 58 R visitPostfix(Postfix node) => visitNodeList(node);
57 R visitPrefix(Prefix node) => visitNodeList(node); 59 R visitPrefix(Prefix node) => visitNodeList(node);
58 R visitReturn(Return node) => visitStatement(node); 60 R visitReturn(Return node) => visitStatement(node);
59 R visitScriptTag(ScriptTag node) => visitNode(node); 61 R visitScriptTag(ScriptTag node) => visitNode(node);
60 R visitSend(Send node) => visitExpression(node); 62 R visitSend(Send node) => visitExpression(node);
61 R visitSendSet(SendSet node) => visitSend(node); 63 R visitSendSet(SendSet node) => visitSend(node);
62 R visitStatement(Statement node) => visitNode(node); 64 R visitStatement(Statement node) => visitNode(node);
63 R visitStringNode(StringNode node) => visitExpression(node); 65 R visitStringNode(StringNode node) => visitExpression(node);
64 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); 66 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node);
65 R visitStringInterpolationPart(StringInterpolationPart node) { 67 R visitStringInterpolationPart(StringInterpolationPart node) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 abstract Token getEndToken(); 138 abstract Token getEndToken();
137 139
138 Block asBlock() => null; 140 Block asBlock() => null;
139 BreakStatement asBreakStatement() => null; 141 BreakStatement asBreakStatement() => null;
140 Cascade asCascade() => null; 142 Cascade asCascade() => null;
141 CascadeReceiver asCascadeReceiver() => null; 143 CascadeReceiver asCascadeReceiver() => null;
142 CaseMatch asCaseMatch() => null; 144 CaseMatch asCaseMatch() => null;
143 CatchBlock asCatchBlock() => null; 145 CatchBlock asCatchBlock() => null;
144 ClassNode asClassNode() => null; 146 ClassNode asClassNode() => null;
147 Combinator asCombinator() => null;
145 Conditional asConditional() => null; 148 Conditional asConditional() => null;
146 ContinueStatement asContinueStatement() => null; 149 ContinueStatement asContinueStatement() => null;
147 DoWhile asDoWhile() => null; 150 DoWhile asDoWhile() => null;
148 EmptyStatement asEmptyStatement() => null; 151 EmptyStatement asEmptyStatement() => null;
149 Export AsExport() => null; 152 Export AsExport() => null;
150 Expression asExpression() => null; 153 Expression asExpression() => null;
151 ExpressionStatement asExpressionStatement() => null; 154 ExpressionStatement asExpressionStatement() => null;
152 For asFor() => null; 155 For asFor() => null;
153 ForIn asForIn() => null; 156 ForIn asForIn() => null;
154 FunctionDeclaration asFunctionDeclaration() => null; 157 FunctionDeclaration asFunctionDeclaration() => null;
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 1773
1771 accept(Visitor visitor) => visitor.visitPartOf(this); 1774 accept(Visitor visitor) => visitor.visitPartOf(this);
1772 1775
1773 visitChildren(Visitor visitor) => name.accept(visitor); 1776 visitChildren(Visitor visitor) => name.accept(visitor);
1774 1777
1775 Token getBeginToken() => partKeyword; 1778 Token getBeginToken() => partKeyword;
1776 1779
1777 Token getEndToken() => name.getEndToken().next; 1780 Token getEndToken() => name.getEndToken().next;
1778 } 1781 }
1779 1782
1783 class Combinator extends Node {
1784 final NodeList identifiers;
1785
1786 final Token keywordToken;
1787
1788 Combinator(this.identifiers, this.keywordToken);
1789
1790 bool get isShow => keywordToken.stringValue === 'show';
1791
1792 bool get isHide => keywordToken.stringValue === 'hide';
1793
1794 Combinator asCombinator() => this;
1795
1796 accept(Visitor visitor) => visitor.visitCombinator(this);
1797
1798 visitChildren(Visitor visitor) => identifiers.accept(visitor);
1799
1800 Token getBeginToken() => keywordToken;
1801
1802 Token getEndToken() => identifiers.getEndToken();
1803 }
1804
1780 class Typedef extends Node { 1805 class Typedef extends Node {
1781 final TypeAnnotation returnType; 1806 final TypeAnnotation returnType;
1782 final Identifier name; 1807 final Identifier name;
1783 final NodeList typeParameters; 1808 final NodeList typeParameters;
1784 final NodeList formals; 1809 final NodeList formals;
1785 1810
1786 final Token typedefKeyword; 1811 final Token typedefKeyword;
1787 final Token endToken; 1812 final Token endToken;
1788 1813
1789 Typedef(this.returnType, this.name, this.typeParameters, this.formals, 1814 Typedef(this.returnType, this.name, this.typeParameters, this.formals,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 * argument). 1976 * argument).
1952 * 1977 *
1953 * TODO(ahe): This method is controversial, the team needs to discuss 1978 * TODO(ahe): This method is controversial, the team needs to discuss
1954 * if top-level methods are acceptable and what naming conventions to 1979 * if top-level methods are acceptable and what naming conventions to
1955 * use. 1980 * use.
1956 */ 1981 */
1957 initializerDo(Node node, f(Node node)) { 1982 initializerDo(Node node, f(Node node)) {
1958 SendSet send = node.asSendSet(); 1983 SendSet send = node.asSendSet();
1959 if (send !== null) return f(send.arguments.head); 1984 if (send !== null) return f(send.arguments.head);
1960 } 1985 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/scanner_task.dart ('k') | dart/lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698