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

查看:123
本文介绍了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天全站免登陆