完成ASN.1源代码时出现错误:“第19行附近的ASN.1语法分析错误(标记“IDENTIFIED”):语法错误,意外的TOK_capitalreference,应为'}'
无法分析“test.asn”

RSI DEFINITIONS AUTOMATIC TAGS ::= BEGIN

MessageFrame ::= SEQUENCE {
    messageId       MESSAGE-ID-AND-TYPE.&id({MessageTypes}),
    value           MESSAGE-ID-AND-TYPE.&Type({MessageTypes}{@.messageId})
}

MESSAGE-ID-AND-TYPE ::= CLASS {
    &id         RSImsgID UNIQUE,
    &Type
} WITH SYNTAX { &Type IDENTIFIED BY &id }

MessageTypes MESSAGE-ID-AND-TYPE ::= {
    { Message1      IDENTIFIED BY message1 } |
    { Message2  IDENTIFIED BY message2 }
}

Message1 ::= SEQUENCE {
    msgCnt          MsgCount,
    id          TemporaryID
}

Message2 ::= SEQUENCE {
    msgCnt          MsgCount,
    id          TemporaryID
}

TemporaryID ::= OCTET STRING (SIZE(4))
MsgCount ::= INTEGER (0..127)
RSImsgID ::= INTEGER (0..32767)
message1    RSImsgID ::= 0 --'00'H
message2    RSImsgID ::= 1 --'01'H
END

编译器显示语法错误。
请帮助我,我在那里面缺少什么。

最佳答案

似乎您正在使用Lev Walkin's asn1c compiler,不幸的是,它还没有完全支持Information对象类。
有一个pending pull request #99你可以试试。另请参见githubissue #108
更新2019-04-11
Information Object ClassInformation Object Set的解析已经完成,并合并到PR #154 master分支中
下面是如何使用当前master分支(commit 88ed3b5c)编译和测试上述ASN.1定义的方法

$ asn1c test.asn
$ make -f converter-example.mk
$ ./converter-example -pMessageFrame -iber <(echo 3010800100a10b3009800101810411223344 | xxd -r -p) -o xer

<MessageFrame>
    <messageId>0</messageId>
    <value>
        <Message1>
            <msgCnt>1</msgCnt>
            <id>11 22 33 44</id>
        </Message1>
    </value>
</MessageFrame>

$ ./converter-example -pMessageFrame -iber <(echo 3010800100a10b3009800101810411223344 | xxd -r -p) -o text
MessageFrame ::= {
    messageId: 0
    value: Message1 ::= {
        msgCnt: 1
        id: 11 22 33 44
    }
}

如果master分支对您不起作用,请尝试使用mouse07410's frok中的vlm_master分支

关于c - ASN源代码意外的TOK_capitalreference,期望为“}”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39011606/

10-11 21:19