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

Side by Side Diff: pkg/analyzer/test/generated/parser_fasta_test.dart

Issue 2948473002: integrating fasta parser (Closed)
Patch Set: Created 3 years, 6 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) 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:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/token.dart' as analyzer; 6 import 'package:analyzer/dart/ast/token.dart' as analyzer;
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/error/error.dart'; 8 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/src/dart/scanner/scanner.dart';
9 import 'package:analyzer/src/fasta/ast_builder.dart'; 10 import 'package:analyzer/src/fasta/ast_builder.dart';
10 import 'package:analyzer/src/fasta/element_store.dart'; 11 import 'package:analyzer/src/fasta/element_store.dart';
11 import 'package:analyzer/src/generated/parser.dart' as analyzer; 12 import 'package:analyzer/src/generated/parser.dart' as analyzer;
12 import 'package:analyzer/src/generated/utilities_dart.dart'; 13 import 'package:analyzer/src/generated/utilities_dart.dart';
14 import 'package:analyzer/src/string_source.dart';
13 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; 15 import 'package:front_end/src/fasta/kernel/kernel_builder.dart';
14 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; 16 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart';
15 import 'package:front_end/src/fasta/parser/identifier_context.dart' 17 import 'package:front_end/src/fasta/parser/identifier_context.dart'
16 show IdentifierContext; 18 show IdentifierContext;
17 import 'package:front_end/src/fasta/parser/parser.dart' as fasta; 19 import 'package:front_end/src/fasta/parser/parser.dart' as fasta;
18 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; 20 import 'package:front_end/src/fasta/scanner/string_scanner.dart';
19 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 21 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
20 import 'package:test/test.dart'; 22 import 'package:test/test.dart';
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; 23 import 'package:test_reflective_loader/test_reflective_loader.dart';
22 24
23 import 'parser_test.dart'; 25 import 'parser_test.dart';
26 import 'test_support.dart';
24 27
25 main() { 28 main() {
26 defineReflectiveSuite(() { 29 defineReflectiveSuite(() {
27 defineReflectiveTests(ClassMemberParserTest_Fasta); 30 defineReflectiveTests(ClassMemberParserTest_Fasta);
28 defineReflectiveTests(ComplexParserTest_Fasta); 31 defineReflectiveTests(ComplexParserTest_Fasta);
29 defineReflectiveTests(ExpressionParserTest_Fasta); 32 defineReflectiveTests(ExpressionParserTest_Fasta);
30 defineReflectiveTests(FormalParameterParserTest_Fasta); 33 defineReflectiveTests(FormalParameterParserTest_Fasta);
31 defineReflectiveTests(StatementParserTest_Fasta); 34 defineReflectiveTests(StatementParserTest_Fasta);
32 defineReflectiveTests(TopLevelParserTest_Fasta); 35 defineReflectiveTests(TopLevelParserTest_Fasta);
33 }); 36 });
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return _parseExpression(code); 383 return _parseExpression(code);
381 } 384 }
382 385
383 @override 386 @override
384 Expression parseCascadeSection(String code) { 387 Expression parseCascadeSection(String code) {
385 var cascadeExpression = _parseExpression('null$code') as CascadeExpression; 388 var cascadeExpression = _parseExpression('null$code') as CascadeExpression;
386 return cascadeExpression.cascadeSections.first; 389 return cascadeExpression.cascadeSections.first;
387 } 390 }
388 391
389 @override 392 @override
390 CompilationUnit parseCompilationUnit(String source, 393 CompilationUnit parseCompilationUnit(String content,
391 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { 394 [List<ErrorCode> expectedErrorCodes = const <ErrorCode>[]]) {
392 return _runParser(source, (parser) => parser.parseUnit, errorCodes) 395 // Scan tokens
393 as CompilationUnit; 396 var source = new StringSource(content, 'parser_test_StringSource.dart');
397 GatheringErrorListener listener = new GatheringErrorListener();
398 var scanner = new Scanner.fasta(source, listener);
399 scanner.scanGenericMethodComments = enableGenericMethodComments;
400 _fastaTokens = scanner.tokenize();
401
402 // Run parser
403 analyzer.Parser parser =
404 new analyzer.Parser(source, listener, useFasta: true);
405 CompilationUnit unit = parser.parseCompilationUnit(_fastaTokens);
406
407 // Assert and return result
408 listener.assertErrorsWithCodes(expectedErrorCodes);
409 return unit;
394 } 410 }
395 411
396 @override 412 @override
397 ConditionalExpression parseConditionalExpression(String code) { 413 ConditionalExpression parseConditionalExpression(String code) {
398 return _parseExpression(code); 414 return _parseExpression(code);
399 } 415 }
400 416
401 @override 417 @override
402 Expression parseConstExpression(String code) { 418 Expression parseConstExpression(String code) {
403 return _parseExpression(code); 419 return _parseExpression(code);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 } 1012 }
997 1013
998 @override 1014 @override
999 @failingTest 1015 @failingTest
1000 void test_parsePartOfDirective_uri() { 1016 void test_parsePartOfDirective_uri() {
1001 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by 1017 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by
1002 // Fasta. 1018 // Fasta.
1003 super.test_parsePartOfDirective_uri(); 1019 super.test_parsePartOfDirective_uri();
1004 } 1020 }
1005 } 1021 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser_fasta.dart ('k') | pkg/front_end/lib/src/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698