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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2721623002: Let parser handle factory modifiers. (Closed)
Patch Set: Handle factory modifiers correctly in dart2js. Created 3 years, 9 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
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 library fasta.parser.parser; 5 library fasta.parser.parser;
6 6
7 import '../scanner.dart' show 7 import '../scanner.dart' show
8 ErrorToken; 8 ErrorToken;
9 9
10 import '../scanner/recover.dart' show 10 import '../scanner/recover.dart' show
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 token, false, staticModifier == null || externalModifier != null); 1813 token, false, staticModifier == null || externalModifier != null);
1814 } 1814 }
1815 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; 1815 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled;
1816 listener.endMethod(getOrSet, start, token); 1816 listener.endMethod(getOrSet, start, token);
1817 return token.next; 1817 return token.next;
1818 } 1818 }
1819 1819
1820 Token parseFactoryMethod(Token token) { 1820 Token parseFactoryMethod(Token token) {
1821 assert(isFactoryDeclaration(token)); 1821 assert(isFactoryDeclaration(token));
1822 Token start = token; 1822 Token start = token;
1823 Token externalModifier; 1823 bool isExternal = false;
1824 if (identical(token.stringValue, 'external')) { 1824 int modifierCount = 0;
1825 externalModifier = token; 1825 while (isModifier(token)) {
1826 token = token.next; 1826 if (optional('external', token)) {
1827 isExternal = true;
1828 }
1829 token = parseModifier(token);
1830 modifierCount++;
1827 } 1831 }
1828 if (optional('const', token)) { 1832 listener.handleModifiers(modifierCount);
1829 token = token.next; // Skip const.
1830 }
1831 Token factoryKeyword = token; 1833 Token factoryKeyword = token;
1832 listener.beginFactoryMethod(factoryKeyword); 1834 listener.beginFactoryMethod(factoryKeyword);
1833 token = token.next; // Skip 'factory'. 1835 token = expect('factory', token);
1834 token = parseConstructorReference(token); 1836 token = parseConstructorReference(token);
1835 token = parseFormalParameters(token); 1837 token = parseFormalParameters(token);
1836 token = parseAsyncModifier(token); 1838 token = parseAsyncModifier(token);
1837 if (optional('=', token)) { 1839 if (optional('=', token)) {
1838 token = parseRedirectingFactoryBody(token); 1840 token = parseRedirectingFactoryBody(token);
1839 } else { 1841 } else {
1840 token = parseFunctionBody(token, false, externalModifier != null); 1842 token = parseFunctionBody(token, false, isExternal);
1841 } 1843 }
1842 listener.endFactoryMethod(start, token); 1844 listener.endFactoryMethod(start, token);
1843 return token.next; 1845 return token.next;
1844 } 1846 }
1845 1847
1846 Token parseOperatorName(Token token) { 1848 Token parseOperatorName(Token token) {
1847 assert(optional('operator', token)); 1849 assert(optional('operator', token));
1848 if (isUserDefinableOperator(token.next.stringValue)) { 1850 if (isUserDefinableOperator(token.next.stringValue)) {
1849 Token operator = token; 1851 Token operator = token;
1850 token = token.next; 1852 token = token.next;
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 break; 3547 break;
3546 } 3548 }
3547 if (isRecoverable) { 3549 if (isRecoverable) {
3548 listener.handleRecoverableError(token, kind, arguments); 3550 listener.handleRecoverableError(token, kind, arguments);
3549 return null; 3551 return null;
3550 } else { 3552 } else {
3551 return listener.handleUnrecoverableError(token, kind, arguments); 3553 return listener.handleUnrecoverableError(token, kind, arguments);
3552 } 3554 }
3553 } 3555 }
3554 } 3556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698