ASN.1 compiler error token “SYNTAX” unexpected

ⅰ亾dé卋堺 提交于 2019-12-20 07:21:24

问题


I'm currently trying to compile a snippet of ASN.1 code. It looks as follows:

RFC1213-MIB DEFINITIONS ::= BEGIN
    IMPORTS 
        experimental FROM RFC1155-SMI
        OBJECT-TYPE FROM RFC-1212;

    mypersonaltest OBJECT IDENTIFIER ::= { experimental 1 }

    tester      OBJECT-TYPE 
        SYNTAX      INTEGER
        ACCESS      read-write
        STATUS      optional
        DESCRIPTION "This is a test"
        ::= { mypersonaltest 1 }

END

Now I'm always getting an error on the line SYNTAX INTEGER:

ASN.1 grammar parse error near line 9 (token "SYNTAX"): syntax error, unexpected TOK_SYNTAX, expecting TOK_PPEQ

Actually, this should work according my example I got here. What am I doing wrong?


回答1:


This looks like an old version of that specification that uses ASN.1 MACRO notation instead of ASN.1 Information Object Classes. The MACRO notation was removed from ASN.1 in 1994. Please consider finding a newer version of your specification that used Information Object Classes instead of the obsolete MACRO notation.

It is possible that the tool you are using does not support ASN.1 MACRO notation (which was removed from ASN.1 in 1994). You could try using the free online compiler at http://asn1-playground.oss.com/ which I believe still supports MACRO notation. Note that the definition of OBJECT-TYPE must be seen by the compiler before "tester" (which uses the OBJECT-TYPE macro) is parsed.

I will repeat, that you will save yourself many headaches if you use a version of your ASN.1 specification that uses Information Object Classes rather than the obsolete ASN.1 MACRO notation.




回答2:


It should be OBJECT-TYPE, not OBJECT TYPE. There is something wrong with the MIB document, and you should try to find a proper version of it.



来源:https://stackoverflow.com/questions/18255794/asn-1-compiler-error-token-syntax-unexpected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!