如何为 .NET Compact Framework 构建 FParsec?
我正在编写一个基于 FParsec 的小型应用程序。
今天,我正在寻找机会制作 Compact Framework 的版本。 显然,为 .NET CF 构建 FParsec 源代码并不是那么简单。 FParsecCS 库包含不安全代码和一些对 CF 中不可用的类型的引用。即,System.Collections.Generic.HashSet
、System.Text.DecoderFallbackException
等。
我想知道是否有什么办法可以让它建成。显然,我试图不更改代码,因为当 FParsec 的进一步版本发布时很难更新。
我其实并不关心性能。如果有一个通用的 CharStream
可以用来代替您拥有的高性能的,那就足够了。
感谢您的帮助。
I’m writing a small application based on FParsec.
Today, I’m looking for an opportunity to make a version for Compact Framework.
Apparently, it is not that simple to build FParsec sources for .NET CF. The FParsecCS library has unsafe code and some references to the types that are not available in CF. Namely, System.Collections.Generic.HashSet
, System.Text.DecoderFallbackException
, and more.
I’m wondering if there’s any way to make it built. Obviously, I’m trying not to alter the code as it would be hard to update when further versions of FParsec released.
I don’t really care about performance. If there is a generic CharStream
that can be used instead of high-performance one you have, that would be quite sufficient.
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有任何使用 .NET CF 的经验,也从未尝试过让 FParsec 在其上运行。不过,FParsec 有一个 Silverlight 版本,这可能是移植到 .NET CF 的一个很好的起点。 Silverlight 版本基于 LOW_TRUST 版本 FParsec,不使用任何“不安全”代码。希望 LOW_TRUST 版本的流大小限制不会成为您的应用程序的问题。
处理
HashSet
依赖项的最简单方法可能是实现您自己的简单HashSet
类型(基于Dictionary
),该类型实现了一些方法FParsec 实际上用于错误处理。如果不支持DecoderFallbackException
,您只需注释掉相应的异常处理程序即可。如果您使用 HG 跟踪更改,那么合并到 FParsec 的更新应该不难。根据 .NET CF 的更改范围,我还可以将它们包含在另一个条件编译器符号的主源代码树中。
I don’t have any experience with .NET CF and never tried to make FParsec run on it. However, there’s a Silverlight version of FParsec, which might be a good starting point for a port to .NET CF. The Silverlight version builds on the LOW_TRUST version of FParsec, which doesn’t use any "unsafe" code. Hopefully, the stream size limitation of the LOW_TRUST version won’t be an issue for your application.
The easiest way to deal with the
HashSet
dependency probably is to implement you own simpleHashSet
type (based on aDictionary
) that implements the few methods that FParsec actually uses for its error handling. If theDecoderFallbackException
is not supported, you can just comment out the respective exception handlers.If you track your changes with HG, it shouldn’t be difficult to merge in updates to FParsec. Depending on how extensive the changes for .NET CF are, I could also include them in the main source tree for another conditional compiler symbol.