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

Side by Side Diff: dart/frog/leg/tree/nodes.dart

Issue 8660004: Parse parenthesized expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: frogsh 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
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/tree/unparser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitClassNode(ClassNode node); 7 R visitClassNode(ClassNode node);
8 R visitDoWhile(DoWhile node); 8 R visitDoWhile(DoWhile node);
9 R visitExpressionStatement(ExpressionStatement node); 9 R visitExpressionStatement(ExpressionStatement node);
10 R visitFor(For node); 10 R visitFor(For node);
11 R visitFunctionExpression(FunctionExpression node); 11 R visitFunctionExpression(FunctionExpression node);
12 R visitIdentifier(Identifier node); 12 R visitIdentifier(Identifier node);
13 R visitIf(If node); 13 R visitIf(If node);
14 R visitLiteralBool(LiteralBool node); 14 R visitLiteralBool(LiteralBool node);
15 R visitLiteralDouble(LiteralDouble node); 15 R visitLiteralDouble(LiteralDouble node);
16 R visitLiteralInt(LiteralInt node); 16 R visitLiteralInt(LiteralInt node);
17 R visitLiteralNull(LiteralNull node); 17 R visitLiteralNull(LiteralNull node);
18 R visitLiteralString(LiteralString node); 18 R visitLiteralString(LiteralString node);
19 R visitNodeList(NodeList node); 19 R visitNodeList(NodeList node);
20 R visitOperator(Operator node); 20 R visitOperator(Operator node);
21 R visitParenthesizedExpression(ParenthesizedExpression node);
21 R visitReturn(Return node); 22 R visitReturn(Return node);
22 R visitSend(Send node); 23 R visitSend(Send node);
23 R visitSendSet(SendSet node); 24 R visitSendSet(SendSet node);
24 R visitThrow(Throw node); 25 R visitThrow(Throw node);
25 R visitTypeAnnotation(TypeAnnotation node); 26 R visitTypeAnnotation(TypeAnnotation node);
26 R visitVariableDefinitions(VariableDefinitions node); 27 R visitVariableDefinitions(VariableDefinitions node);
27 R visitWhile(While node); 28 R visitWhile(While node);
28 } 29 }
29 30
30 Token firstBeginToken(Node first, Node second) { 31 Token firstBeginToken(Node first, Node second) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 FunctionExpression asFunctionExpression() => this; 79 FunctionExpression asFunctionExpression() => this;
79 Identifier asIdentifier() => this; 80 Identifier asIdentifier() => this;
80 If asIf() => this; 81 If asIf() => this;
81 LiteralBool asLiteralBool() => this; 82 LiteralBool asLiteralBool() => this;
82 LiteralDouble asLiteralDouble() => this; 83 LiteralDouble asLiteralDouble() => this;
83 LiteralInt asLiteralInt() => this; 84 LiteralInt asLiteralInt() => this;
84 LiteralNull asLiteralNull() => this; 85 LiteralNull asLiteralNull() => this;
85 LiteralString asLiteralString() => this; 86 LiteralString asLiteralString() => this;
86 NodeList asNodeList() => this; 87 NodeList asNodeList() => this;
87 Operator asOperator() => this; 88 Operator asOperator() => this;
89 ParenthesizedExpression asParenthesizedExpression() => this;
88 Return asReturn() => this; 90 Return asReturn() => this;
89 Send asSend() => this; 91 Send asSend() => this;
90 SendSet asSendSet() => this; 92 SendSet asSendSet() => this;
91 Throw asThrow() => this; 93 Throw asThrow() => this;
92 TypeAnnotation asTypeAnnotation() => this; 94 TypeAnnotation asTypeAnnotation() => this;
93 VariableDefinitions asVariableDefinitions() => this; 95 VariableDefinitions asVariableDefinitions() => this;
94 While asWhile() => this; 96 While asWhile() => this;
95 } 97 }
96 98
97 class ClassNode extends Node { 99 class ClassNode extends Node {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 Block(this.statements); 261 Block(this.statements);
260 262
261 accept(Visitor visitor) => visitor.visitBlock(this); 263 accept(Visitor visitor) => visitor.visitBlock(this);
262 264
263 Token getBeginToken() => statements.getBeginToken(); 265 Token getBeginToken() => statements.getBeginToken();
264 266
265 Token getEndToken() => statements.getEndToken(); 267 Token getEndToken() => statements.getEndToken();
266 } 268 }
267 269
268 class If extends Statement { 270 class If extends Statement {
269 final NodeList condition; 271 final ParenthesizedExpression condition;
270 final Statement thenPart; 272 final Statement thenPart;
271 final Statement elsePart; 273 final Statement elsePart;
272 274
273 final Token ifToken; 275 final Token ifToken;
274 final Token elseToken; 276 final Token elseToken;
275 277
276 If(this.condition, this.thenPart, this.elsePart, 278 If(this.condition, this.thenPart, this.elsePart,
277 this.ifToken, this.elseToken); 279 this.ifToken, this.elseToken);
278 280
279 bool get hasElsePart() => elsePart !== null; 281 bool get hasElsePart() => elsePart !== null;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 While(Expression this.condition, Statement body, 534 While(Expression this.condition, Statement body,
533 Token this.whileKeyword) : super(body); 535 Token this.whileKeyword) : super(body);
534 536
535 accept(Visitor visitor) => visitor.visitWhile(this); 537 accept(Visitor visitor) => visitor.visitWhile(this);
536 538
537 Token getBeginToken() => whileKeyword; 539 Token getBeginToken() => whileKeyword;
538 540
539 Token getEndToken() => body.getEndToken(); 541 Token getEndToken() => body.getEndToken();
540 } 542 }
541 543
544 class ParenthesizedExpression extends Expression {
545 final Expression expression;
546 final BeginGroupToken beginToken;
547
548 ParenthesizedExpression(Expression this.expression,
549 BeginGroupToken this.beginToken);
550
551 accept(Visitor visitor) => visitor.visitParenthesizedExpression(this);
552
553 Token getBeginToken() => beginToken;
554
555 Token getEndToken() => beginToken.endGroup;
556 }
557
542 /** Representation of modifiers such as static, abstract, final, etc. */ 558 /** Representation of modifiers such as static, abstract, final, etc. */
543 class Modifiers { 559 class Modifiers {
544 final Link<Token> modifiers; 560 final Link<Token> modifiers;
545 /** Bit pattern to easy check what modifiers are present. */ 561 /** Bit pattern to easy check what modifiers are present. */
546 final int flags; 562 final int flags;
547 563
548 const Modifiers([this.modifiers, this.flags = 0]); 564 const Modifiers([this.modifiers, this.flags = 0]);
549 } 565 }
OLDNEW
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698