Giter VIP home page Giter VIP logo

Comments (8)

kimgr avatar kimgr commented on August 28, 2024

It could be that dependencies are not wired between modules -- I have quite elaborate logic in place to detect dependencies and generate assignments in dependency order, not sure if this carries over to multiple modules. Also not sure how hard it would be to make that happen.

from asn1ate.

aholtzma avatar aholtzma commented on August 28, 2024

Wouldn't the dependencies be handled at the semantic level? The parse tree doesn't even have these modules.

from asn1ate.

kimgr avatar kimgr commented on August 28, 2024

Yes, at the semantic level.

Oh, now I see you say PDU-definitions disappears from the parse tree... I think that might be because --parse only dumps the parse tree of the first module, but I'm not sure. Take a look in test.py.

from asn1ate.

aholtzma avatar aholtzma commented on August 28, 2024

Attached is a minimal test case for multi-modules with a dependency.
multi-module.asn1.txt

The result is actually different than what I see with the rrc.asn. In this case the parse sees both modules. It fails on resolving the cross module depenency though:

Boo-definitions DEFINITIONS AUTOMATIC TAGS ::=

BEGIN

  Yourenum ::= ENUMERATED { five, six, seven }

END

Foo-definitions DEFINITIONS AUTOMATIC TAGS ::=

BEGIN

IMPORTS
  Yourenum
FROM
  Boo-definitions;

  Mysequence-with-enum  ::=      SEQUENCE 
  {
    foo Yourenum DEFAULT two,
    bar ENUMERATED { a, b, c} DEFAULT c
  }

END

outputs:

WARNING: More than one module generated to the same stream.
# Auto-generated by asn1ate v.0.5.1.dev from multi-module.asn1.txt
# (last modified on 2016-09-09 16:01:43)

from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
import foo_definitions


class Yourenum(univ.Enumerated):
    pass


Yourenum.namedValues = namedval.NamedValues(
    ('five', 0),
    ('six', 1),
    ('seven', 2)
)


# Auto-generated by asn1ate v.0.5.1.dev from multi-module.asn1.txt
# (last modified on 2016-09-09 16:01:43)

from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
import boo_definitions


class Mysequence_with_enum(univ.Sequence):
    pass


Traceback (most recent call last):
  File "asn1ate/pyasn1gen.py", line 633, in <module>
    sys.exit(main())
  File "asn1ate/pyasn1gen.py", line 624, in main
    generate_pyasn1(module, output_file, modules)
  File "asn1ate/pyasn1gen.py", line 497, in generate_pyasn1
    return Pyasn1Backend(sema_module, out_stream, referenced_modules).generate_code()
  File "asn1ate/pyasn1gen.py", line 145, in generate_code
    details = self.generate_definition(assignment)
  File "asn1ate/pyasn1gen.py", line 159, in generate_definition
    return self.generate_defn(assigned_type, type_decl)
  File "asn1ate/pyasn1gen.py", line 171, in generate_defn
    return generator(class_name, t)
  File "asn1ate/pyasn1gen.py", line 210, in defn_constructed_type
    fragment.write_block(self.inline_component_types(t.components))
  File "asn1ate/pyasn1gen.py", line 321, in inline_component_types
    component_exprs.append(self.generate_expr(c))
  File "asn1ate/pyasn1gen.py", line 167, in generate_expr
    return generator(t)
  File "asn1ate/pyasn1gen.py", line 424, in inline_component_type
    type_expr = self.generate_expr(t.type_decl)
  File "asn1ate/pyasn1gen.py", line 167, in generate_expr
    return generator(t)
  File "asn1ate/pyasn1gen.py", line 337, in inline_tagged_type
    type_expr += '.subtype(%s=%s)' % (tag_implicitness, self.build_tag_expr(t))
  File "asn1ate/pyasn1gen.py", line 351, in build_tag_expr
    tagged_type_decl = self.sema_module.resolve_type_decl(tag_def.type_decl, self.referenced_modules)
  File "/Users/aholtzma/src/asn1ate/asn1ate/sema.py", line 303, in resolve_type_decl
    return module.resolve_type_decl(module.user_types()[type_decl.type_name], referenced_modules)
KeyError: 'Yourenum'

So I think this may be two different problems - first the parsing problem, second the inter-module hookup.

from asn1ate.

kimgr avatar kimgr commented on August 28, 2024

Thanks for the contained repro.

I seem to recall this PR added support for emitting modules to individual files, maybe that would help here? Looks like there's a --split argument to pyasn1gen.py.

from asn1ate.

kimgr avatar kimgr commented on August 28, 2024

Oh, now I see you say PDU-definitions disappears from the parse tree... I think that might be because
--parse only dumps the parse tree of the first module, but I'm not sure.

This turned out to be caused by a bug in the grammar. which caused the rest of the module to be consumed by the IMPORTS parser rule. I have a fix/simplification in the works.

from asn1ate.

mungayree avatar mungayree commented on August 28, 2024

I think is still seem to occur on on cloned tree (asn1ate v.0.6.1.dev0). Is it checked in yet ?

from asn1ate.

kimgr avatar kimgr commented on August 28, 2024

No, I don't think I ever got around to solving this entirely. It was harder than I thought, and I ran out of time.

from asn1ate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.