支持扩展 XER/RXER 的 ASN.1 编译器
我正在拼命寻找一个 ASN.1 编译器,它能够成功解析我从客户那里获得的预定义 ASN.1 定义。
到目前为止,没有任何产品(免费或商业)能够解析该定义,该定义是基于 XER 的,并且具有一些暂时的 RXER 依赖性 - 当我手动指定相关的 ASN.1 定义(取自 RFC)时,编译器也会发出解析器错误。
相关代码行是(简化的):
MYMSG ::= SEQUENCE
{
msgID [ATTRIBUTE] [250] UTF8String OPTIONAL,
msgType UTF8String
}
每个编译器都会抱怨 [ATTRIBUTE] 标记,所以我发现这是 RFC 4912 中定义的 ASN.X 规范的一部分,并且还依赖于 RFC 4910 中对 RXER 的支持,另请参阅 X。 680-1。
问题是我尝试过的每个编译器似乎都不支持这些开箱即用的编码模式,并且无法解析 RFC 中提到的定义,例如对于 RXER 以及我得到的使用此编码的所有定义:
“RXER.asn”,第 20 行 (附加基本定义):A1139W: 默认编码参考'RXER' 对于模块 “附加基本定义”是 未知和所有编码指令 在由此标识的模块内 编码参考将被忽略。
接收器说明
(注意:所有依赖模块(如 ASN.X)都在“DEFINITIONS”标记之后立即包含指令“RXER INSTRUCTIONS”,我尝试过的任何编译器都无法理解该指令)。
我尝试了 openasn1 (www.openasn1.org) - 有趣的是,我得到的代码中有一些旧的且部分功能的 Java 映射对象,这些对象是由 openasn1 生成的! - http://lionet.info/asn1c/asn1c.cgi 上的在线编译器和各种商业编译器Objective Systems ASN1C v6.4.1 等工具位于 http://www.obj-sys.com/ Cnge641Dwld/acv64kits.php(他们甚至有一个最新的 Eclipse 插件),Marben http://www.marben-products.com/asn.1/tce_java.html 和 unigone http://www.unigone.com/en/products/Asn1Compiler/description
我总是收到与此类似的错误:
ASN.1 grammar parse error near line 13 (token "ATTRIBUTE"): parse error, unexpected TOK_capitalreference, expecting TOK_number
我是否缺少一些明显的内容,例如导入或其他定义/编译器标志?
I am desperately searching for an ASN.1 compiler that will successfully parse a predefined ASN.1 definition I got from a customer.
None of the products (free or commercial) so far was able to parse the definition, which is XER based and has some transient RXER dependency - when I specify the relevant ASN.1-definitions manually (taken from the RFCs), the compiler also emits parser errors.
The relevant code line is (simplified):
MYMSG ::= SEQUENCE
{
msgID [ATTRIBUTE] [250] UTF8String OPTIONAL,
msgType UTF8String
}
Every compiler complains about the [ATTRIBUTE] token, so I found this is part of the ASN.X specification defined in RFC 4912 and also depends on support for RXER in RFC 4910, see also X.680-1.
Problem is every compiler I tried does not seem to support these encoding schemas out of the box and fails to parse the definitions mentioned in the RFCs, e.g. for RXER and all definitions that use this encoding I get:
"RXER.asn", line 20
(AdditionalBasicDefinitions): A1139W:
The default encoding reference 'RXER'
for the module
'AdditionalBasicDefinitions' is
unknown and all encoding instructions
within the module identified by this
encoding reference will be ignored.
RXER INSTRUCTIONS
(Note: all dependent modules like ASN.X include the instruction "RXER INSTRUCTIONS" immediately after the "DEFINITIONS"-tag, which is not understood by any compiler I tried).
I tried openasn1 (www.openasn1.org) - funny thing is that I have some old and partially functional Java mapping objects in the code I got that was generated by openasn1! - the online compiler at http://lionet.info/asn1c/asn1c.cgi and various commercial tools like Objective Systems ASN1C v6.4.1 at http://www.obj-sys.com/Cnge641Dwld/acv64kits.php (they even have a current Eclipse plugin), Marben http://www.marben-products.com/asn.1/tce_java.html and unigone http://www.unigone.com/en/products/Asn1Compiler/description
I always get an error similar to this:
ASN.1 grammar parse error near line 13 (token "ATTRIBUTE"): parse error, unexpected TOK_capitalreference, expecting TOK_number
Am I missing something obvious like IMPORTs or other definitions/compiler flags?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我成功地编译了模式并生成了所需的 Java 映射类。我不得不使用商业 OSS Nokalva 编译器,因为我尝试的所有免费工具都失败了(E)XER 编码模式。
我收到的模式中也存在一些错误,因此我必须执行以下操作:
指示:
<块引用>
定义 XER 指令自动标签 ::=
在页脚中,我添加了 XER 编码指令:
<块引用>
编码控制 XER 全局默认值
修改编码
使用 XER 编码时,必须显式指定标签以避免语法中的歧义:
<块引用>
[属性] [标签:0]
而不是模棱两可的定义
[属性] [0]
所有这些问题都通过查阅 EXER-encoding< 上的这篇精彩文章得到解决/a>,绝对是一本好书,感谢 Nokalva 提供的这份有用的文档!
I managed to compile the schema and generate the needed Java mapping classes. I had to use the commercial OSS Nokalva compiler, as all free tools I tried failed on (E)XER encoded schemata.
There were also some errors in the schema I received, so here is what I had to do:
directive:
in the footer, I added the XER encoding directive:
when using XER encoding, you have to explicitly specify tags to avoid ambiguities in syntax:
All these problems were resolved by consulting this nice writeup on EXER-encoding, definitely a good read and thanks to Nokalva for this helpful documentation!