| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'package:front_end/src/fasta/errors.dart'; | 5 import 'package:front_end/src/fasta/errors.dart' show internalError; |
| 6 import 'package:front_end/src/fasta/fasta_codes.dart' show FastaMessage; |
| 6 import 'package:front_end/src/fasta/parser/identifier_context.dart'; | 7 import 'package:front_end/src/fasta/parser/identifier_context.dart'; |
| 7 import 'package:front_end/src/fasta/parser/parser.dart'; | 8 import 'package:front_end/src/fasta/parser/parser.dart'; |
| 9 import 'package:front_end/src/fasta/source/stack_listener.dart'; |
| 8 import 'package:front_end/src/scanner/token.dart'; | 10 import 'package:front_end/src/scanner/token.dart'; |
| 9 import 'package:front_end/src/fasta/source/stack_listener.dart'; | |
| 10 import 'package:front_end/src/scanner/token.dart' as analyzer; | |
| 11 | 11 |
| 12 /// "Mini AST" representation of a declaration which can accept annotations. | 12 /// "Mini AST" representation of a declaration which can accept annotations. |
| 13 class AnnotatedNode { | 13 class AnnotatedNode { |
| 14 final Comment documentationComment; | 14 final Comment documentationComment; |
| 15 | 15 |
| 16 final List<Annotation> metadata; | 16 final List<Annotation> metadata; |
| 17 | 17 |
| 18 AnnotatedNode(this.documentationComment, List<Annotation> metadata) | 18 AnnotatedNode(this.documentationComment, List<Annotation> metadata) |
| 19 : metadata = metadata ?? const []; | 19 : metadata = metadata ?? const []; |
| 20 } | 20 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 48 ClassMember(Comment documentationComment, List<Annotation> metadata) | 48 ClassMember(Comment documentationComment, List<Annotation> metadata) |
| 49 : super(documentationComment, metadata); | 49 : super(documentationComment, metadata); |
| 50 } | 50 } |
| 51 | 51 |
| 52 /// "Mini AST" representation of a comment. | 52 /// "Mini AST" representation of a comment. |
| 53 class Comment { | 53 class Comment { |
| 54 final bool isDocumentation; | 54 final bool isDocumentation; |
| 55 | 55 |
| 56 final List<Token> tokens; | 56 final List<Token> tokens; |
| 57 | 57 |
| 58 factory Comment(analyzer.Token commentToken) { | 58 factory Comment(Token commentToken) { |
| 59 var tokens = <Token>[]; | 59 var tokens = <Token>[]; |
| 60 bool isDocumentation = false; | 60 bool isDocumentation = false; |
| 61 while (commentToken != null) { | 61 while (commentToken != null) { |
| 62 if (commentToken.lexeme.startsWith('/**') || | 62 if (commentToken.lexeme.startsWith('/**') || |
| 63 commentToken.lexeme.startsWith('///')) { | 63 commentToken.lexeme.startsWith('///')) { |
| 64 isDocumentation = true; | 64 isDocumentation = true; |
| 65 } | 65 } |
| 66 tokens.add(commentToken); | 66 tokens.add(commentToken); |
| 67 commentToken = commentToken.next; | 67 commentToken = commentToken.next; |
| 68 } | 68 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 push('$prefix.$suffix'); | 426 push('$prefix.$suffix'); |
| 427 } | 427 } |
| 428 | 428 |
| 429 @override | 429 @override |
| 430 void handleType(Token beginToken, Token endToken) { | 430 void handleType(Token beginToken, Token endToken) { |
| 431 debugEvent("Type"); | 431 debugEvent("Type"); |
| 432 List<TypeName> typeArguments = pop(); | 432 List<TypeName> typeArguments = pop(); |
| 433 String name = pop(); | 433 String name = pop(); |
| 434 push(new TypeName(name, typeArguments)); | 434 push(new TypeName(name, typeArguments)); |
| 435 } | 435 } |
| 436 |
| 437 @override |
| 438 void addCompileTimeErrorFromMessage(FastaMessage message) { |
| 439 internalError(message.message); |
| 440 } |
| 436 } | 441 } |
| 437 | 442 |
| 438 /// Parser intended for use with [MiniAstBuilder]. | 443 /// Parser intended for use with [MiniAstBuilder]. |
| 439 class MiniAstParser extends Parser { | 444 class MiniAstParser extends Parser { |
| 440 MiniAstParser(MiniAstBuilder listener) : super(listener); | 445 MiniAstParser(MiniAstBuilder listener) : super(listener); |
| 441 | 446 |
| 442 Token parseArgumentsOpt(Token token) { | 447 Token parseArgumentsOpt(Token token) { |
| 443 MiniAstBuilder listener = this.listener; | 448 MiniAstBuilder listener = this.listener; |
| 444 if (listener.inMetadata) { | 449 if (listener.inMetadata) { |
| 445 return super.parseArgumentsOpt(token); | 450 return super.parseArgumentsOpt(token); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 465 final String name; | 470 final String name; |
| 466 | 471 |
| 467 final List<TypeName> typeArguments; | 472 final List<TypeName> typeArguments; |
| 468 | 473 |
| 469 TypeName(this.name, this.typeArguments); | 474 TypeName(this.name, this.typeArguments); |
| 470 } | 475 } |
| 471 | 476 |
| 472 /// "Mini AST" representation of an expression which summary code generation | 477 /// "Mini AST" representation of an expression which summary code generation |
| 473 /// need not be concerned about. | 478 /// need not be concerned about. |
| 474 class UnknownExpression extends Expression {} | 479 class UnknownExpression extends Expression {} |
| OLD | NEW |