OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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.md file. | |
4 | |
5 import 'package:testing/testing.dart'; | |
Siggi Cherem (dart-lang)
2017/01/12 21:56:04
I'm curious to take a look at this package in more
ahe
2017/01/13 07:16:21
I have outstanding reviews for landing it, but you
| |
6 | |
7 import 'package:scanner/scanner.dart'; | |
8 | |
9 import 'package:scanner/testing/scanner_chain.dart'; | |
10 | |
11 import 'package:parser/parser.dart'; | |
12 | |
13 Future<ChainContext> createContext( | |
14 Chain suite, Map<String, String> enviroment) async { | |
15 return new ScannerContext(); | |
16 } | |
17 | |
18 class ScannerContext extends ChainContext { | |
19 final List<Step> steps = const <Step>[ | |
20 const Read(), | |
21 const Scan(), | |
22 const Parse(), | |
23 ]; | |
24 } | |
25 | |
26 class Parse extends Step<ScannerResult, Null, ChainContext> { | |
27 const Parse(); | |
28 | |
29 String get name => "parse"; | |
30 | |
31 Future<Result<Null>> run( | |
32 ScannerResult result, ChainContext context) async { | |
33 try { | |
34 List<ParserError> errors = parse(result.tokens); | |
35 if (errors.isNotEmpty) { | |
36 return fail(null, errors.join("\n")); | |
37 } | |
38 } on ParserError catch (e, s) { | |
39 return fail(null, e, s); | |
40 } | |
41 return pass(null); | |
42 } | |
43 } | |
44 | |
45 main(List<String> arguments) => runMe(arguments, createContext); | |
OLD | NEW |