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

Side by Side Diff: runtime/vm/parser.h

Issue 1574213005: Report missing semicolons after function declarations (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef VM_PARSER_H_ 5 #ifndef VM_PARSER_H_
6 #define VM_PARSER_H_ 6 #define VM_PARSER_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 bool is_part_source() const { 287 bool is_part_source() const {
288 return script_.kind() == RawScript::kSourceTag; 288 return script_.kind() == RawScript::kSourceTag;
289 } 289 }
290 290
291 // Parsing library patch script. 291 // Parsing library patch script.
292 bool is_patch_source() const { 292 bool is_patch_source() const {
293 return script_.kind() == RawScript::kPatchTag; 293 return script_.kind() == RawScript::kPatchTag;
294 } 294 }
295 295
296 intptr_t TokenPos() const { return tokens_iterator_.CurrentPosition(); } 296 intptr_t TokenPos() const { return tokens_iterator_.CurrentPosition(); }
297 intptr_t PrevTokenPos() const { return prev_token_pos_; }
297 298
298 Token::Kind CurrentToken() { 299 Token::Kind CurrentToken() {
299 if (token_kind_ == Token::kILLEGAL) { 300 if (token_kind_ == Token::kILLEGAL) {
300 ComputeCurrentToken(); 301 ComputeCurrentToken();
301 } 302 }
302 return token_kind_; 303 return token_kind_;
303 } 304 }
304 305
305 void ComputeCurrentToken(); 306 void ComputeCurrentToken();
306 307
307 RawLibraryPrefix* ParsePrefix(); 308 RawLibraryPrefix* ParsePrefix();
308 309
309 Token::Kind LookaheadToken(int num_tokens); 310 Token::Kind LookaheadToken(int num_tokens);
310 String* CurrentLiteral() const; 311 String* CurrentLiteral() const;
311 RawDouble* CurrentDoubleLiteral() const; 312 RawDouble* CurrentDoubleLiteral() const;
312 RawInteger* CurrentIntegerLiteral() const; 313 RawInteger* CurrentIntegerLiteral() const;
313 314
314 // Sets parser to given token position in the stream. 315 // Sets parser to given token position in the stream.
315 void SetPosition(intptr_t position); 316 void SetPosition(intptr_t position);
316 317
317 void ConsumeToken() { 318 void ConsumeToken() {
318 // Reset cache and advance the token. 319 // Reset cache and advance the token.
320 prev_token_pos_ = tokens_iterator_.CurrentPosition();
319 token_kind_ = Token::kILLEGAL; 321 token_kind_ = Token::kILLEGAL;
320 tokens_iterator_.Advance(); 322 tokens_iterator_.Advance();
321 INC_STAT(thread(), num_tokens_consumed, 1); 323 INC_STAT(thread(), num_tokens_consumed, 1);
322 } 324 }
323 void ConsumeRightAngleBracket(); 325 void ConsumeRightAngleBracket();
324 void CheckToken(Token::Kind token_expected, const char* msg = NULL); 326 void CheckToken(Token::Kind token_expected, const char* msg = NULL);
325 void ExpectToken(Token::Kind token_expected); 327 void ExpectToken(Token::Kind token_expected);
326 void ExpectSemicolon(); 328 void ExpectSemicolon();
327 void UnexpectedToken(); 329 void UnexpectedToken();
328 String* ExpectUserDefinedTypeIdentifier(const char* msg); 330 String* ExpectUserDefinedTypeIdentifier(const char* msg);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 static void ReportError(const Error& error); 369 static void ReportError(const Error& error);
368 370
369 // Concatenate and report an already formatted error and a new error message. 371 // Concatenate and report an already formatted error and a new error message.
370 static void ReportErrors(const Error& prev_error, 372 static void ReportErrors(const Error& prev_error,
371 const Script& script, intptr_t token_pos, 373 const Script& script, intptr_t token_pos,
372 const char* format, ...) PRINTF_ATTRIBUTE(4, 5); 374 const char* format, ...) PRINTF_ATTRIBUTE(4, 5);
373 375
374 // Report error message at location of current token in current script. 376 // Report error message at location of current token in current script.
375 void ReportError(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); 377 void ReportError(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3);
376 378
379 void ReportErrorBefore(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
380
377 // Report error message at given location in current script. 381 // Report error message at given location in current script.
378 void ReportError(intptr_t token_pos, 382 void ReportError(intptr_t token_pos,
379 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4); 383 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4);
380 384
381 // Report warning message at location of current token in current script. 385 // Report warning message at location of current token in current script.
382 void ReportWarning(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3); 386 void ReportWarning(const char* msg, ...) const PRINTF_ATTRIBUTE(2, 3);
383 387
384 // Report warning message at given location in current script. 388 // Report warning message at given location in current script.
385 void ReportWarning(intptr_t token_pos, 389 void ReportWarning(intptr_t token_pos,
386 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4); 390 const char* msg, ...) const PRINTF_ATTRIBUTE(3, 4);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 530
527 void SetupDefaultsForOptionalParams(const ParamList& params); 531 void SetupDefaultsForOptionalParams(const ParamList& params);
528 ClosureNode* CreateImplicitClosureNode(const Function& func, 532 ClosureNode* CreateImplicitClosureNode(const Function& func,
529 intptr_t token_pos, 533 intptr_t token_pos,
530 AstNode* receiver); 534 AstNode* receiver);
531 static void AddFormalParamsToFunction(const ParamList* params, 535 static void AddFormalParamsToFunction(const ParamList* params,
532 const Function& func); 536 const Function& func);
533 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope); 537 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope);
534 538
535 SequenceNode* ParseConstructor(const Function& func); 539 SequenceNode* ParseConstructor(const Function& func);
536 SequenceNode* ParseFunc(const Function& func); 540 SequenceNode* ParseFunc(const Function& func, bool check_semicolon);
537 541
538 void ParseNativeFunctionBlock(const ParamList* params, const Function& func); 542 void ParseNativeFunctionBlock(const ParamList* params, const Function& func);
539 543
540 SequenceNode* ParseInstanceGetter(const Function& func); 544 SequenceNode* ParseInstanceGetter(const Function& func);
541 SequenceNode* ParseInstanceSetter(const Function& func); 545 SequenceNode* ParseInstanceSetter(const Function& func);
542 SequenceNode* ParseStaticFinalGetter(const Function& func); 546 SequenceNode* ParseStaticFinalGetter(const Function& func);
543 SequenceNode* ParseStaticInitializer(); 547 SequenceNode* ParseStaticInitializer();
544 SequenceNode* ParseMethodExtractor(const Function& func); 548 SequenceNode* ParseMethodExtractor(const Function& func);
545 SequenceNode* ParseNoSuchMethodDispatcher(const Function& func); 549 SequenceNode* ParseNoSuchMethodDispatcher(const Function& func);
546 SequenceNode* ParseInvokeFieldDispatcher(const Function& func); 550 SequenceNode* ParseInvokeFieldDispatcher(const Function& func);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 Thread* thread() const { return thread_; } 830 Thread* thread() const { return thread_; }
827 Isolate* isolate() const { return isolate_; } 831 Isolate* isolate() const { return isolate_; }
828 Zone* zone() const { return thread_->zone(); } 832 Zone* zone() const { return thread_->zone(); }
829 833
830 Isolate* isolate_; // Cached current isolate. 834 Isolate* isolate_; // Cached current isolate.
831 Thread* thread_; 835 Thread* thread_;
832 836
833 Script& script_; 837 Script& script_;
834 TokenStream::Iterator tokens_iterator_; 838 TokenStream::Iterator tokens_iterator_;
835 Token::Kind token_kind_; // Cached token kind for current token. 839 Token::Kind token_kind_; // Cached token kind for current token.
840 intptr_t prev_token_pos_;
836 Block* current_block_; 841 Block* current_block_;
837 842
838 // is_top_level_ is true if parsing the "top level" of a compilation unit, 843 // is_top_level_ is true if parsing the "top level" of a compilation unit,
839 // that is class definitions, function type aliases, global functions, 844 // that is class definitions, function type aliases, global functions,
840 // global variables. 845 // global variables.
841 bool is_top_level_; 846 bool is_top_level_;
842 847
843 // await_is_keyword_ is true if we are parsing an async or generator 848 // await_is_keyword_ is true if we are parsing an async or generator
844 // function. In this context the identifiers await, async and yield 849 // function. In this context the identifiers await, async and yield
845 // are treated as keywords. 850 // are treated as keywords.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 893
889 // Indentation of parser trace. 894 // Indentation of parser trace.
890 intptr_t trace_indent_; 895 intptr_t trace_indent_;
891 896
892 DISALLOW_COPY_AND_ASSIGN(Parser); 897 DISALLOW_COPY_AND_ASSIGN(Parser);
893 }; 898 };
894 899
895 } // namespace dart 900 } // namespace dart
896 901
897 #endif // VM_PARSER_H_ 902 #endif // VM_PARSER_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698