且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以使用Treetop解析IO吗?

更新时间:2021-11-10 23:31:23

据我从源代码看,您实际上只能传递一个String.因此,您的选择基本上是遵循Josh Voigts的想法在他的评论中或实现反向IOString:具有String接口,但懒惰"地从File中获取请求的内容.

As far as I can glance from the source code, you can indeed only pass a String in. So your options are basically to either follow the idea of Josh Voigts in his comment or to implement something of a reverse IOString: something that has a String interface, but 'lazily' fetches the requested contents from a File.

我不确定是否不借助C就可以做到这一点,即使那样,有些方法的语义也是如此,以至于根本无法一致地实现它们,但是Treetop使用的String方法的子集可能是这样的:它是可管理的.但是,我想说乔什·沃格茨(Josh Voigts)的回答最为实用.

I'm not entirely sure whether that is even possible without resorting to C and even then there may be methods whose semantics are such that they simply cannot be implemented consistently, but perhaps the subset of String methods used by Treetop is such that it is manageable. However, I'd say Josh Voigts answer is most pragmatic.