OLD | NEW |
---|---|
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 final bool VERBOSE = false; | 5 final bool VERBOSE = false; |
6 | 6 |
7 /** | 7 /** |
8 * A parser event listener that does nothing except throw exceptions | 8 * A parser event listener that does nothing except throw exceptions |
9 * on parser errors. | 9 * on parser errors. |
10 */ | 10 */ |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 PartialFieldListElement(Token this.beginToken, | 1523 PartialFieldListElement(Token this.beginToken, |
1524 Token this.endToken, | 1524 Token this.endToken, |
1525 Modifiers modifiers, | 1525 Modifiers modifiers, |
1526 Element enclosing) | 1526 Element enclosing) |
1527 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing); | 1527 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing); |
1528 | 1528 |
1529 VariableDefinitions parseNode(DiagnosticListener listener) { | 1529 VariableDefinitions parseNode(DiagnosticListener listener) { |
1530 if (cachedNode != null) return cachedNode; | 1530 if (cachedNode != null) return cachedNode; |
1531 cachedNode = parse(listener, | 1531 cachedNode = parse(listener, |
1532 getCompilationUnit(), | 1532 getCompilationUnit(), |
1533 (p) => p.parseVariablesDeclaration(beginToken)); | 1533 (p) => p.parseVariablesDeclaration(beginToken)); |
ahe
2012/08/02 19:40:24
I think we should rework this change to a "recover
| |
1534 if (!cachedNode.modifiers.isVar() && | |
1535 !cachedNode.modifiers.isFinal() && | |
1536 !cachedNode.modifiers.isConst() && | |
1537 cachedNode.type === null) { | |
1538 listener.cancel('A field declaration must start with var, final, ' | |
1539 'const, or a type annotation.', | |
1540 cachedNode); | |
1541 } | |
1534 return cachedNode; | 1542 return cachedNode; |
1535 } | 1543 } |
1536 | 1544 |
1537 Token position() => beginToken; // findMyName doesn't work. I'm nameless. | 1545 Token position() => beginToken; // findMyName doesn't work. I'm nameless. |
1538 } | 1546 } |
1539 | 1547 |
1540 class PartialTypedefElement extends TypedefElement { | 1548 class PartialTypedefElement extends TypedefElement { |
1541 final Token token; | 1549 final Token token; |
1542 | 1550 |
1543 PartialTypedefElement(SourceString name, Element enclosing, this.token) | 1551 PartialTypedefElement(SourceString name, Element enclosing, this.token) |
(...skipping 12 matching lines...) Expand all Loading... | |
1556 | 1564 |
1557 Node parse(DiagnosticListener diagnosticListener, | 1565 Node parse(DiagnosticListener diagnosticListener, |
1558 CompilationUnitElement element, | 1566 CompilationUnitElement element, |
1559 doParse(Parser parser)) { | 1567 doParse(Parser parser)) { |
1560 NodeListener listener = new NodeListener(diagnosticListener, element); | 1568 NodeListener listener = new NodeListener(diagnosticListener, element); |
1561 doParse(new Parser(listener)); | 1569 doParse(new Parser(listener)); |
1562 Node node = listener.popNode(); | 1570 Node node = listener.popNode(); |
1563 assert(listener.nodes.isEmpty()); | 1571 assert(listener.nodes.isEmpty()); |
1564 return node; | 1572 return node; |
1565 } | 1573 } |
OLD | NEW |