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

Parsing Error: pyparsing.ParseException: Expected "DEFINITIONS" #58

Open
twix1312 opened this issue Nov 16, 2017 · 5 comments
Open

Parsing Error: pyparsing.ParseException: Expected "DEFINITIONS" #58

twix1312 opened this issue Nov 16, 2017 · 5 comments

Comments

@twix1312
Copy link

I'm trying to convert an LTE specification's ASN.1 syntax into python code and ran the file (see attached zip) in pyasn1gen.py.

I received the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/asn1ate/pyasn1gen.py", line 649, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/asn1ate/pyasn1gen.py", line 627, in main
    parse_tree = parser.parse_asn1(asn1def)
  File "/usr/lib/python2.7/site-packages/asn1ate/parser.py", line 40, in parse_asn1
    parse_result = grammar.parseString(asn1_definition)
  File "/usr/lib/python2.7/site-packages/pyparsing.py", line 1632, in parseString
    raise exc
pyparsing.ParseException: Expected "DEFINITIONS" (at char 195), (line:8, col:13)

The attached file was taken from here. I had to filter out the ASN.1 definitions and remove unwanted text.

I might have made a mistake doing that. Could you please help?
gtp.zip

@kimgr
Copy link
Owner

kimgr commented Nov 16, 2017

It might be a while until I get to this, but this: pyparsing.ParseException: Expected "DEFINITIONS" (at char 195), (line:8, col:13) is a good place to start. You can run your ASN.1 through http://asn1-playground.oss.com/ first, to make sure it's valid.

asn1ate does not support all of ASN.1 so there may be something that's missing, and the line/column from the error message might give a clue as to what it is.

@twix1312
Copy link
Author

twix1312 commented Nov 16, 2017 via email

@kimgr
Copy link
Owner

kimgr commented Nov 17, 2017

So is line 195, col 37 at the end of the file? Can you upload the ASN.1 as text so I can see it?

@twix1312
Copy link
Author

I've attached the ASN.1 as a textfile (its 6600 lines long!)

If you just want that specific portion:
FROM S1AP-Constants;

-- **************************************************************
--
-- Interface Elementary Procedure Class
--
-- **************************************************************

S1AP-ELEMENTARY-PROCEDURE ::= CLASS {
	&InitiatingMessage				,
	&SuccessfulOutcome							OPTIONAL,
	&UnsuccessfulOutcome						OPTIONAL,
	&procedureCode				ProcedureCode 	UNIQUE,
	&criticality				Criticality 	DEFAULT ignore
}

its the "{" brace after "S1AP-ELEMENTARY-PROCEDURE ::= CLASS".
gtp.txt

@kimgr
Copy link
Owner

kimgr commented Nov 17, 2017

Yeah, that explains it. asn1ate doesn't support CLASSes, and I don't really know where to start on that, so I think it's safe to assume that it won't do so unless you can spare time to work on it yourself.

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

2 participants