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

Unified Diff: dart/frog/leg/scanner/listener.dart

Issue 8879052: Add --ast to mini_parser.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: More failures after merging with Florian's constructor changes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/frog/leg/scanner/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/scanner/listener.dart
diff --git a/dart/frog/leg/scanner/listener.dart b/dart/frog/leg/scanner/listener.dart
index aeedb041ae893617402697a97d3e0d274959d8a7..7eca9aa31673e7f22485c48b0e6b225702610af0 100644
--- a/dart/frog/leg/scanner/listener.dart
+++ b/dart/frog/leg/scanner/listener.dart
@@ -558,6 +558,13 @@ class NodeListener extends ElementListener {
pushNode(makeNodeList(memberCount, beginToken, endToken, null));
}
+ void endTopLevelMethod(Token beginToken, Token endToken) {
+ Statement body = popNode();
+ NodeList formalParameters = popNode();
+ Identifier name = popNode();
+ pushElement(new PartialFunctionElement(name.source, beginToken, endToken));
+ }
+
void endFormalParameter(Token token) {
NodeList name = new NodeList.singleton(popNode());
TypeAnnotation type = popNode();
@@ -805,6 +812,7 @@ class NodeListener extends ElementListener {
if (count === 0) return;
// TODO(ahe): Implement this.
canceler.cancel("initializers are not implemented", token: beginToken);
+ discardNodes(count);
}
void handleNoInitializers() {
@@ -831,16 +839,20 @@ class NodeListener extends ElementListener {
void endMethod(Token beginToken, Token endToken) {
Statement body = popNode();
+ NodeList formalParameters = popNode();
Identifier name = popNode(); // TODO(ahe): What about constructors?
// TODO(ahe): Save modifiers.
- pushNode(new FunctionExpression(name, null, null, null));
+ pushNode(new FunctionExpression(name, formalParameters, body, null));
+ // TODO(ahe): We don't need to push the AST node and record the
+ // member. This should be cleaned up, preferably by moving the
+ // element stuff to a separate class.
ElementKind kind = isConstructor(name) ?
ElementKind.CONSTRUCTOR :
ElementKind.FUNCTION;
Element memberElement =
new PartialFunctionElement(name.source, beginToken, endToken,
kind, enclosingElement);
- enclosingElement.addMember(memberElement);
+ enclosingElement.addMember(memberElement);
}
void endLiteralMapEntry(Token token) {
@@ -977,10 +989,10 @@ class PartialFunctionElement extends FunctionElement {
PartialFunctionElement(SourceString name,
Token this.beginToken, Token this.endToken,
- ElementKind kind,
- [Element enclosing = null])
+ [ElementKind kind = ElementKind.FUNCTION,
+ Element enclosing = null])
: super(name, kind, enclosing);
-
+
FunctionExpression parseNode(Canceler canceler, Logger logger) {
if (node != null) return node;
node = parse(canceler, logger, (p) => p.parseFunction(beginToken));
« no previous file with comments | « no previous file | dart/frog/leg/scanner/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698