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

Side by Side Diff: dart/lib/compiler/implementation/tools/mini_parser.dart

Issue 10913176: Reject non-ASCII identifiers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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('parser'); 5 #library('parser');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 8
9 #import('../../../utf/utf.dart'); 9 #import('../../../utf/utf.dart');
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 : new Parser(listener); 98 : new Parser(listener);
99 try { 99 try {
100 Token token = scan(file); 100 Token token = scan(file);
101 if (!options.scanOnly) parser.parseUnit(token); 101 if (!options.scanOnly) parser.parseUnit(token);
102 } on ParserError catch (ex) { 102 } on ParserError catch (ex) {
103 if (options.throwOnError) { 103 if (options.throwOnError) {
104 throw; 104 throw;
105 } else { 105 } else {
106 print(ex); 106 print(ex);
107 } 107 }
108 } on MalformedInputException catch (ex) {
109 // Already diagnosed.
110 } catch (ex) { 108 } catch (ex) {
111 print('Error in file: $filename'); 109 print('Error in file: $filename');
112 throw; 110 throw;
113 } 111 }
114 if (options.buildAst) { 112 if (options.buildAst) {
115 MyNodeListener l = listener; 113 MyNodeListener l = listener;
116 if (!l.nodes.isEmpty()) { 114 if (!l.nodes.isEmpty()) {
117 String message = 'Stack not empty after parsing'; 115 String message = 'Stack not empty after parsing';
118 print(formatError(message, l.nodes.head.getBeginToken(), 116 print(formatError(message, l.nodes.head.getBeginToken(),
119 l.nodes.head.getEndToken(), file)); 117 l.nodes.head.getEndToken(), file));
120 throw message; 118 throw message;
121 } 119 }
122 } 120 }
123 } 121 }
124 122
125 Token scan(MySourceFile source) { 123 Token scan(MySourceFile source) {
126 Scanner scanner = new ByteArrayScanner(source.rawText); 124 Scanner scanner = new ByteArrayScanner(source.rawText);
127 try { 125 return scanner.tokenize();
128 return scanner.tokenize();
129 } on MalformedInputException catch (ex) {
130 if (ex.position is Token) {
131 print(formatError(ex.message, ex.position, ex.position, source));
132 } else {
133 Token fakeToken = new Token(QUESTION_INFO, ex.position);
134 print(formatError(ex.message, fakeToken, fakeToken, source));
135 }
136 throw;
137 }
138 } 126 }
139 127
140 var filesWithCrashes; 128 var filesWithCrashes;
141 129
142 void parseFilesFrom(InputStream input, MyOptions options, Function whenDone) { 130 void parseFilesFrom(InputStream input, MyOptions options, Function whenDone) {
143 void readLine(String line) { 131 void readLine(String line) {
144 stopwatch.start(); 132 stopwatch.start();
145 try { 133 try {
146 parseFile(line, options); 134 parseFile(line, options);
147 } catch (ex, trace) { 135 } catch (ex, trace) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 set text(String newText) { 309 set text(String newText) {
322 throw "not supported"; 310 throw "not supported";
323 } 311 }
324 } 312 }
325 313
326 class Mock { 314 class Mock {
327 const Mock(); 315 const Mock();
328 bool get useColors => true; 316 bool get useColors => true;
329 internalError(message) { throw message.toString(); } 317 internalError(message) { throw message.toString(); }
330 } 318 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/token.dart ('k') | dart/tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698