Skip to content

How to listen to the parsed result immediately? #110

Answered by renggli
dhaval15 asked this question in Q&A
Discussion options

You must be logged in to vote

Probably the easiest is if you split this into two separate parsing steps: You can use the Result of the meta-data parser to build the data parser, as well as to resume the parse where the meta-data parser completed. Something along these lines:

final metadataResult = metadataParser.parse(input);
final dataParser = buildDataParser(metadataResult.value);
final dataResult = dataParser.parseOn(metadataResult);

Alternatively you can use the ContinuationParser to merge this into a single parser that returns the result of the data parser:

final parser = metadataParser.callCC((continuation, context) {
  final metadataResult = continuation(context);
  final dataParser = buildDataParser(metadataRe…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by renggli
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #109 on May 29, 2021 17:04.