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

Side by Side Diff: 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
« no previous file with comments | « petitparser/lib/src/dart/grammar.dart ('k') | petitparser/lib/src/debug/profile.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 part of debug;
2
3 /**
4 * Handler function for the [ContinuationParser].
5 */
6 typedef Result ContinuationHandler(
7 Result continuation(Context context), Context context);
8
9 /**
10 * Continuation parser that when activated captures a continuation function
11 * and passes it together with the current context into the handler.
12 *
13 * Handlers are not required to call the continuation, but can completely ignore
14 * it, call it multiple times, and/or store it away for later use. Similarly
15 * handlers can modify the current context and/or modify the returned result.
16 *
17 * The following example shows a simple wrapper. Messages are printed before and
18 * after the `digit()` parser is activated:
19 *
20 * var wrapped = digit();
21 * var parser = new ContinuationParser(wrapped, (continuation, context) {
22 * print('Parser will be activated, the context is $context.');
23 * var result = continuation(context);
24 * print('Parser was activated, the result is $result.');
25 * return result;
26 * });
27 *
28 * See [profile], [progress], and [trace] for more elaborate examples.
29 */
30 class ContinuationParser extends DelegateParser {
31 final ContinuationHandler handler;
32
33 ContinuationParser(parser, this.handler) : super(parser);
34
35 @override
36 Result parseOn(Context context) {
37 return handler((result) => super.parseOn(result), context);
38 }
39
40 @override
41 Parser copy() => new ContinuationParser(children[0], handler);
42 }
OLDNEW
« no previous file with comments | « petitparser/lib/src/dart/grammar.dart ('k') | petitparser/lib/src/debug/profile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698