Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to parse INTEGER single value with syntax "|" #40

Closed
FredLien opened this issue Aug 25, 2016 · 3 comments
Closed

Fail to parse INTEGER single value with syntax "|" #40

FredLien opened this issue Aug 25, 2016 · 3 comments

Comments

@FredLien
Copy link

FredLien commented Aug 25, 2016

Hi,

I have recently used asn1ate to translate ASN.1 file to python code.
The case of following cannot correctly generate code.
I paste the patch code to solve this.
FYI

ASN.1

Network-Device ::= SEQUENCE {
    port-num               INTEGER (0 .. 255),
    port-lane              INTEGER ( 0 | 1 | 2 | 4 ),
    port-speed             INTEGER ( 0 | 1000 | 10000 | 250000 ),
    ...
}
## patch code:

diff --git a/asn1ate/parser.py b/asn1ate/parser.py
index b8e3623..e9970a9 100644
--- a/asn1ate/parser.py
+++ b/asn1ate/parser.py
@@ -236,8 +236,9 @@ def _build_asn1_grammar():
     # todo: consider the full subtype and general constraint syntax described in 45.*
     lower_bound = (constraint_real_value | signed_number | referenced_value | MIN)
     upper_bound = (constraint_real_value | signed_number | referenced_value | MAX)
-    single_value_constraint = Suppress('(') + value + Suppress(')')
## \+    single_value_constraint = Suppress('(') + Optional(Group(delimitedList(value, delim='|'))) + Suppress(')')

Regards,
FredLien

@FredLien
Copy link
Author

Sorry, I find it's duplicate with "Single value constraint handled as a list #14."
Please ignore above information.
Thanks.

@mungayree
Copy link

mungayree commented Mar 30, 2017

I think below are some statements of ASN.1 the current version do not handle -
So a user need to replicate the IMPORT by copy and paste.
IMPORTS abc-xyz FROM Top-Component
and

Network-Device ::= SEQUENCE {
    port-num               INTEGER (0 .. 255 | 10000 ), <------------- this case
    port-lane              INTEGER ( 0 | 1 | 2 | 4 ),
    port-speed             INTEGER ( 0 | 1000 | 10000 | 250000 ),
    ...
}

at times there spec which do this, but the patch does not seem to work on it.

@kimgr
Copy link
Owner

kimgr commented Jun 9, 2019

This is now fixed on master.

@kimgr kimgr closed this as completed Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants