buildingSMART / mvdXML

Repository used by the mvdXML group to support mvdXML specification and implementation.
28 stars 10 forks source link

INTEGER with SIZE checks in the Grammar #28

Open pjanck opened 2 years ago

pjanck commented 2 years ago

State

Documentation, chapter 4, grammar:

value : logical_literal | real_literal | regular_expression | string_literal;

Documentation, Table 19, Description of metric values:

SIZE: Indicates the size of a collection or STRING (value is an INTEGER).

Question

value cannot be type-safely an integer, although there is an int defined in the grammar. Thoughts?

Proposal

Expand value to include int_literal. I can prepare a PR if wished.

MatthiasWeise commented 2 years ago

Having an int_literal might be a good option, although we could also argue that int is included in real_literal. In order to have more type safety we would have to bind the metrics SIZE to an int_literal. Can you make a proposal?

SergejMuhic commented 2 years ago

I would vote for int_literal instead of real_literal. It also rounds up the basic types nicely (apart from char, date and byte which are a bit debatable for checking purposes? 😄 ).

MatthiasWeise commented 2 years ago

Yes for SIZE metrics, but we still need real_literal for VALUE metrics.

SergejMuhic commented 2 years ago

Misunderstanding. I have meant that instead of using real_literal also for an integer, we introduce int_literal.

pjanck commented 2 years ago

we introduce int_literal Can you make a proposal?

Yes, I'll prepare a PR.

In order to have more type safety we would have to bind the metrics SIZE to an int_literal.

This isn't that easy with the generality of the grammar. Consider that real_literal also doesn't make sense with TYPE checks - and that is not explicitly forbidden in the grammar. I believe that - as it currently stands - a note in the documentation suffices.