提振精神2:有没有办法知道什么是解析器进展百分比是多少? [英] boost spirit 2 : is there a way to know what is the parser progression percentage?

查看:129
本文介绍了提振精神2:有没有办法知道什么是解析器进展百分比是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法解析PGN文件分成几个游戏<一个href=\"http://stackoverflow.com/questions/34163728/how-can-i-simply-consume-unrecognized-characters\">mainly感谢这个论坛。

I managed to parse a pgn file into several games mainly thanks to this forum.

不过,我要处理这么多场比赛中的文件,该过程可能需要我最近的电脑上两分钟。这就是为什么我希望动画使用此解析器的GUI应用程序的进度条。

However, as the files I have to deal with have so many games, the process can take two minutes on my recent computer. That's why I would like to animate a progress bar on the GUI application using this parser.

我觉得最简单的方法是要问的精神,他有多少个字符已经处理过,有多少字符保持。 (或者有多少行保持,并已处理)。

I think the easiest way would be to "ask" spirit how many characters he has already processed, and how many characters remain. (Or how many lines remain and have been processed).

这可能吗?如果是这样,我怎么需要修改解析器文件,以获得这个比例?

Is it possible ? If so, how do I need to modify the parser file in order to get this ratio ?

推荐答案

您可以使用 line_pos_iterator 和潜在的 iter_pos 从仓库中原始的。

You can use line_pos_iterator and potentially the iter_pos primitive from the repository.


  • (@ GuyGreer :)有没有办法知道的回溯涉及的金额(否则,就不需要首先要回溯)。所以,做的最好的事情就是接受你得到某种平均吞吐量,它可以是一个有点突发性或有时laggy的。如果你的语法是不平衡的,这些变化比噪音多,你应该考虑在首位固定语法/分析器定义。

  • (@GuyGreer:) There is no way to know the amount of backtracking involved (otherwise, there would not need to be backtracking in the first place). So, the best thing to do is accept that you get some kind of "average throughput" that can be a little bursty or laggy at times. If your grammar is that unbalanced that these variations are more than noise, you should consider fixing the the grammar/parser definitions in the first place.

要对付问题不知道流的长度,你不能修复它比没有它作为流等。

To counter the "problem" of not knowing the stream length, you cannot fix it other than not having it as a stream.

我建议内存映射。您可以使用的设施,距离的boost :: iostream的的boost ::进程间或只是 MMAP

I'd suggest memory mapping. You can use the facilities from boost::iostreams, boost::interprocess or just mmap.

我估计我至少有3个答案,证明每个在这个回答中提到的技术,所以我只是搜索这个网站他们。

I estimate I have at least 3 answers demonstrating each of the techniques mentioned in this answer, so I'd just search this site for them.

这篇关于提振精神2:有没有办法知道什么是解析器进展百分比是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆