kellerkindt / asn1rs

Generates Rust Code and optionally compatible Protobuf schema files from ASN.1 definitions.
http://asn1.rs
Apache License 2.0
54 stars 19 forks source link

asn1rs chokes on empty SEQUENCE #44

Closed harmic closed 3 years ago

harmic commented 3 years ago

I was attempting to use asn1rs to produce a rust codec for the 3GPP RRC protocol (38.331. It immediately bombs out with this error:

Failed to load file rrc.asn: Model(At line 36, column 34 expected text, but instead got: '}'
   0: <asn1rs_model::model::ComponentTypeList as core::convert::TryFrom<&mut core::iter::adapters::Peekable<alloc::vec::IntoIter<asn1rs_model::parser::Token>>>>::try_from
   1: asn1rs_model::model::Model<asn1rs_model::model::Asn>::read_sequence_or_sequence_of
   2: asn1rs_model::model::Model<asn1rs_model::model::Asn>::read_role_given_text
   3: <asn1rs_model::model::Choice as core::convert::TryFrom<&mut core::iter::adapters::Peekable<alloc::vec::IntoIter<asn1rs_model::parser::Token>>>>::try_from
   4: asn1rs_model::model::Model<asn1rs_model::model::Asn>::try_from
   5: asn1rs::converter::Converter::load_file
   6: asn1rs::main
   7: std::sys_common::backtrace::__rust_begin_short_backtrace
   8: std::rt::lang_start::{{closure}}
   9: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/ops/function.rs:259:13
      std::panicking::try::do_call
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:381:40
      std::panicking::try
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:345:19
      std::panic::catch_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panic.rs:396:14
      std::rt::lang_start_internal
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/rt.rs:51:25
  10: main
  11: __libc_start_main
  12: <unknown>

)

It is complaining about the field messageClassExtension field below:

BCCH-DL-SCH-MessageType ::= CHOICE {
    c1                      CHOICE {
        systemInformation                       SystemInformation,
        systemInformationBlockType1             SystemInformationBlockType1
    },
    messageClassExtension   SEQUENCE {}
}

I'm not sure why they have these empty SEQEUNCE fields, presumably something to do with extensibility.

I was using asn1rs 0.2.0.

kellerkindt commented 3 years ago

Thats wired, but shouldn't happen. Hopefully I will be able to fix this in the coming days. Thanks for reporting