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

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

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

Powered by Google App Engine
This is Rietveld 408576698