asn1c icon indicating copy to clipboard operation
asn1c copied to clipboard

Parse CSTA 3 scheme

Open vidilab opened this issue 4 years ago • 4 comments

When trying to compile CSTA-3, asn1c is giving an error when parsing rose94.asn1.

ASN.1 grammar parse error near line 129 (token "{"): syntax error, unexpected '{', expecting '}' Cannot parse "../../data/CSTA3/rose94.asn1" The mentioned line contains:

	returnError	[3]	ReturnError {{Errors{{Returnable}}}},

in context:

ROS {InvokeId:InvokeIdSet, OPERATION:Invokable, OPERATION:Returnable} ::= CHOICE
{
	invoke		[1]	Invoke {{InvokeIdSet}, {Invokable}},
	returnResult	[2]	ReturnResult {{Returnable}},
	returnError	[3]	ReturnError {{Errors{{Returnable}}}},
	reject		[4]	Reject
}

CSTA ASN.1 files: https://www.ecma-international.org/wp-content/uploads/ECMA-285_4th_edition_source_files.zip

vidilab avatar Jul 19 '21 16:07 vidilab

Hi @vidilab,

As a workaround try removing ``{{Returnable}}` from the returnError definition

ROS {InvokeId:InvokeIdSet, OPERATION:Invokable, OPERATION:Returnable} ::= CHOICE
{
	invoke		[1]	Invoke {{InvokeIdSet}, {Invokable}},
	returnResult	[2]	ReturnResult {{Returnable}},
	returnError	[3]	ReturnError {{Errors}},
	reject		[4]	Reject
}

As this specification heavily uses Information Object Class you may try the mouse07410's fork of asn1c as well.

velichkov avatar Jul 20 '21 06:07 velichkov

The workaround of removing {{Returnable}} works for this asn1c, but is not needed for the mouse fork. But both this and the mouse fork then error at another point: rose94.asn1:133 (token "!"): syntax error, unexpected '!', expecting ')'

(CONSTRAINED BY { -- must conform to the above definition -- }
! RejectProblem : general-unrecognisedPDU)

It seems the ! symbol is not supported in a constraint. Removing all constraints, then yields another error: ASN.1 grammar parse error near line 137 (token "present"): syntax error, unexpected TOK_identifier. Mouse fork yields a similar error at the same line: (token "present"): syntax error, unexpected identifier.

	linkedId	 CHOICE {
						present	[0]	IMPLICIT	present <	InvokeId,
						absent	[1]	IMPLICIT NULL
							}

vidilab avatar Jul 20 '21 08:07 vidilab

Try removing the present <. I'm not familiar with this ASN.1 construct and I don't know how it is called.

velichkov avatar Jul 20 '21 11:07 velichkov

That helps but not sure what are the effects on semantics if any. Other lines the compiler does not like:

ASN.1 grammar parse error near line 260 (token "ERROR"): syntax error, unexpected TOK_capitalreference, expecting TOK_PPEQ

Errors {OPERATION:Operations} ERROR ::= {Operations.&Errors}

ASN.1 grammar parse error near line 263 (token "operation"): syntax error, unexpected TOK_identifier, expecting TOK_typereference or TOK_capitalreference

Bind {OPERATION:operation} ::= CHOICE
{
	bind-invoke	[16] OPERATION.&ArgumentType({operation}),
	bind-result	[17] OPERATION.&ResultType ({operation}),
	bind-error	[18] OPERATION.&Errors.&ParameterType ({operation})
}

ASN.1 grammar parse error near line 290 (token "OPERATION"): syntax error, unexpected TOK_capitalreference, expecting TOK_PPEQ

Forward {OPERATION:OperationSet} OPERATION ::=
{
	OperationSet |
	OperationSet.&Linked.&Linked |
	OperationSet.&Linked.&Linked.&Linked.&Linked
}

and so on...

I guess it is simply using too much unsupported constructs.

vidilab avatar Jul 20 '21 12:07 vidilab