Not possible to extract assumed_value in grammar at c_terminology_code


The c_terminology_code constraint in the grammer looks like this
c_terminology_code: '[' ( ( AC_CODE ( ';' AT_CODE )? ) | AT_CODE ) ']' ;

It is therefor in the generated code not possible to distinguish the different attributes of the C_TERMINOLOGY_CLASS, because, there are only two functions generated in the ADLParser: AT_CODE and AC_CODE, while the first can be situated on two locations.

The best way to handle assumed_value is to create a grammar rule for it, like it is done in many other constraints, like f.e.

c_time: ( TIME_CONSTRAINT_PATTERN | time_value | time_list_value | time_interval_value | time_interval_list_value ) assumed_time_value? ;
assumed_time_value: ';' time_value ;




Thomas Beale
February 2, 2016, 11:13 AM

You can only have an assumed value in the ac_code case, so it can't just be added optionally to the end. So the rule looks right to me. I suspect an Antlr code generator error.

Bert Verhees
February 2, 2016, 3:01 PM

Ok, I proceed in github

Thomas Beale
February 2, 2016, 3:41 PM

If you can think of an alternate rule that expresses the same intention, but causes correct code generation, let me know. If you also think the code generation is not correct, it could be worth reporting to the antlr team - it's not hard to do.

Bert Verhees
February 2, 2016, 4:54 PM

I tested it, it works as it should, and a simplifciation, I cannot think of one. So we can close the case, and maybe document the reason for the grammar better in the specs-document

(a assumedvalue is only possible if the constraint value is an ac-code), it took some time for I grasped that

Thomas Beale
February 4, 2016, 2:18 PM

I have added a comment to the Antlr grammar to clarify this.


Bert Verhees




Affects versions