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

Side by Side Diff: packages/petitparser/lib/src/debug/continuation.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
(Empty)
1 part of petitparser.debug;
2
3 /// Handler function for the [ContinuationParser].
4 typedef Result ContinuationHandler(
5 Result continuation(Context context), Context context);
6
7 /// Continuation parser that when activated captures a continuation function
8 /// and passes it together with the current context into the handler.
9 ///
10 /// Handlers are not required to call the continuation, but can completely ignor e
11 /// it, call it multiple times, and/or store it away for later use. Similarly
12 /// handlers can modify the current context and/or modify the returned result.
13 ///
14 /// The following example shows a simple wrapper. Messages are printed before an d
15 /// after the `digit()` parser is activated:
16 ///
17 /// var wrapped = digit();
18 /// var parser = new ContinuationParser(wrapped, (continuation, context) {
19 /// print('Parser will be activated, the context is $context.');
20 /// var result = continuation(context);
21 /// print('Parser was activated, the result is $result.');
22 /// return result;
23 /// });
24 ///
25 /// See [profile], [progress], and [trace] for more elaborate examples.
26 class ContinuationParser extends DelegateParser {
27 final ContinuationHandler handler;
28
29 ContinuationParser(parser, this.handler) : super(parser);
30
31 @override
32 Result parseOn(Context context) {
33 return handler((result) => super.parseOn(result), context);
34 }
35
36 @override
37 Parser copy() => new ContinuationParser(children[0], handler);
38 }
OLDNEW
« no previous file with comments | « packages/petitparser/lib/src/dart/grammar.dart ('k') | packages/petitparser/lib/src/debug/profile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698