ANTLR 是序列化/反序列化二进制数据格式的合适工具吗? [英] Is ANTLR an appropriate tool to serialize/deserialize a binary data format?

查看:35
本文介绍了ANTLR 是序列化/反序列化二进制数据格式的合适工具吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要读取和写入八位字节流以通过各种网络发送以与智能电表进行通信.有一个 ANSI 标准 ANSI C12.19,它描述了二进制数据格式.虽然数据格式并不过分复杂,但标准非常大(500 多页),因为它描述了许多不同的类型.该标准完全由 EBNF 语法描述.我正在考虑使用 ANTLR 来读取 EBNF 语法或其修改版本,并创建可以读写八位字节流的 C# 类.

I need to read and write octet streams to send over various networks to communicate with smart electric meters. There is an ANSI standard, ANSI C12.19, that describes the binary data format. While the data format is not overly complex the standard is very large (500+ pages) in that it describes many distinct types. The standard is fully described by an EBNF grammar. I am considering utilizing ANTLR to read the EBNF grammar or a modified version of it and create C# classes that can read and write the octet stream.

这是对 ANTLR 的一个很好的使用吗?

Is this a good use of ANTLR?

如果是这样,我需要做什么才能使用 ANTLR 3.1?通过搜索新闻组档案,似乎我需要实现一个可以读取字节而不是字符的新流.这是全部还是我还必须实施 Lexer 派生词?

If so, what do I need to do to be able to utilize ANTLR 3.1? From searching the newsgroup archives it seems like I need to implement a new stream that can read bytes instead of characters. Is that all or would I have to implement a Lexer derivative as well?

如果 ANTLR 可以帮助我读取/解析流,它也可以帮助我编写流吗?

If ANTLR can help me read/parse the stream can it also help me write the stream?

谢谢.

丹·菲努坎

推荐答案

这个主题不时出现在 ANTLR 邮件列表中.答案通常是否定的,因为二进制文件格式非常常规,不值得为此付出代价.

This subject comes up from time to time on the ANTLR mailing list. The answer is usually no, because binary file formats are very regular and it's just not worth the overhead.

这篇关于ANTLR 是序列化/反序列化二进制数据格式的合适工具吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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