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

Side by Side Diff: pkg/compiler/lib/src/native/scanner.dart

Issue 2899043006: cleanup fasta token classes (Closed)
Patch Set: Created 3 years, 7 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import '../common.dart'; 5 import '../common.dart';
6 import '../parser/element_listener.dart' show ElementListener; 6 import '../parser/element_listener.dart' show ElementListener;
7 import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token; 7 import 'package:front_end/src/fasta/scanner.dart' show Token;
8 import 'package:front_end/src/fasta/scanner/token_constants.dart' as Tokens 8 import 'package:front_end/src/fasta/scanner/token_constants.dart' as Tokens
9 show STRING_TOKEN; 9 show STRING_TOKEN;
10 import 'package:front_end/src/scanner/token.dart' show BeginToken;
10 11
11 void checkAllowedLibrary(ElementListener listener, Token token) { 12 void checkAllowedLibrary(ElementListener listener, Token token) {
12 if (listener.scannerOptions.canUseNative) return; 13 if (listener.scannerOptions.canUseNative) return;
13 listener.reportErrorFromToken(token, MessageKind.NATIVE_NOT_SUPPORTED); 14 listener.reportErrorFromToken(token, MessageKind.NATIVE_NOT_SUPPORTED);
14 } 15 }
15 16
16 Token handleNativeBlockToSkip(ElementListener listener, Token token) { 17 Token handleNativeBlockToSkip(ElementListener listener, Token token) {
17 checkAllowedLibrary(listener, token); 18 checkAllowedLibrary(listener, token);
18 token = token.next; 19 token = token.next;
19 if (identical(token.kind, Tokens.STRING_TOKEN)) { 20 if (identical(token.kind, Tokens.STRING_TOKEN)) {
20 token = token.next; 21 token = token.next;
21 } 22 }
22 if (identical(token.stringValue, '{')) { 23 if (identical(token.stringValue, '{')) {
23 BeginGroupToken beginGroupToken = token; 24 BeginToken beginGroupToken = token;
24 token = beginGroupToken.endGroup; 25 token = beginGroupToken.endGroup;
25 } 26 }
26 return token; 27 return token;
27 } 28 }
28 29
29 Token handleNativeFunctionBody(ElementListener listener, Token token) { 30 Token handleNativeFunctionBody(ElementListener listener, Token token) {
30 checkAllowedLibrary(listener, token); 31 checkAllowedLibrary(listener, token);
31 Token begin = token; 32 Token begin = token;
32 listener.beginReturnStatement(token); 33 listener.beginReturnStatement(token);
33 token = token.next; 34 token = token.next;
34 bool hasExpression = false; 35 bool hasExpression = false;
35 if (identical(token.kind, Tokens.STRING_TOKEN)) { 36 if (identical(token.kind, Tokens.STRING_TOKEN)) {
36 hasExpression = true; 37 hasExpression = true;
37 listener.beginLiteralString(token); 38 listener.beginLiteralString(token);
38 token = token.next; 39 token = token.next;
39 listener.endLiteralString(0, token); 40 listener.endLiteralString(0, token);
40 } 41 }
41 listener.endReturnStatement(hasExpression, begin, token); 42 listener.endReturnStatement(hasExpression, begin, token);
42 // TODO(ngeoffray): expect a ';'. 43 // TODO(ngeoffray): expect a ';'.
43 // Currently there are method with both native marker and Dart body. 44 // Currently there are method with both native marker and Dart body.
44 return token.next; 45 return token.next;
45 } 46 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/native/resolver.dart ('k') | pkg/compiler/lib/src/parser/element_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698