ASN源代码意外的TOK_capitalreference,期待'}'

问题描述 投票:1回答:2

完成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

编译器显示语法错误。请帮助我,我错过了什么。

c asn.1
2个回答
3
投票

您似乎正在使用Lev Walkin's asn1c compiler,遗憾的是它尚未完全支持信息对象类。

你可以尝试一个pending pull request #99。另见github issue #108

更新2019-04-11

Information Object ClassInformation Object Set的解析已经完成并合并在masterPR #154 分支

以下是如何使用当前的master分支编译和测试上述ASN.1定义(commit 88ed3b5c

$ 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分支不起作用,请尝试使用vlm_mastermouse07410's frok分支


1
投票

使用http://asn1-playground.oss.com/正确编译模式。最有可能的是,您使用的编译器未正确实现WITH SYNTAX功能。您可以尝试修改模式,以便不使用WITH SYNTAX并使用标准语法编写对象集初始化,即:

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

MessageTypes MESSAGE-ID-AND-TYPE ::= {
    { &Type Message1, &id message1 } | 
    { &Type Message2, &id message2 }
}
© www.soinside.com 2019 - 2024. All rights reserved.