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

Side by Side Diff: petitparser/lib/src/debug/trace.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/debug/progress.dart ('k') | petitparser/lib/src/json/grammar.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 * Returns a transformed [parser] that when being used to read input prints a
5 * trace of all activated parsers and their respective parse results.
6 *
7 * For example, the snippet
8 *
9 * var parser = letter() & word().star();
10 * trace(parser).parse('f1');
11 *
12 * produces the following output:
13 *
14 * Instance of 'SequenceParser'
15 * Instance of 'CharacterParser'[letter expected]
16 * Success[1:2]: f
17 * Instance of 'PossessiveRepeatingParser'[0..*]
18 * Instance of 'CharacterParser'[letter or digit expected]
19 * Success[1:3]: 1
20 * Instance of 'CharacterParser'[letter or digit expected]
21 * Failure[1:3]: letter or digit expected
22 * Success[1:3]: [1]
23 * Success[1:3]: [f, [1]]
24 *
25 * Indentation signifies the activation of a parser object. Reverse indentation
26 * signifies the returning of a parse result either with a success or failure
27 * context.
28 */
29 Parser trace(Parser parser, [OutputHandler output = print]) {
30 var level = 0;
31 return transformParser(parser, (each) {
32 return new ContinuationParser(each, (continuation, context) {
33 output('${_repeat(level, ' ')}${each}');
34 level++;
35 var result = continuation(context);
36 level--;
37 output('${_repeat(level, ' ')}${result}');
38 return result;
39 });
40 });
41 }
OLDNEW
« no previous file with comments | « petitparser/lib/src/debug/progress.dart ('k') | petitparser/lib/src/json/grammar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698