grammars-v4
grammars-v4 copied to clipboard
[OCL] Types are missing in collection operations
https://www.omg.org/spec/OCL/2.4/PDF section 7.6.1 states
As a final extension to the select syntax, the expected type of the variable v can be given. The select now is written as:
collection->select( v : Type | boolean-expression-with-v )
But the OCL grammar here doesn't allow type before the bar.
https://github.com/antlr/grammars-v4/blob/222722b82514b0fcbd300e4991851621c6be1c86/ocl/OCL.g4#L272
Do I miss anything? Can you double check if this grammar rule is wrong?
I might have time to fix it if a revision is needed.
self.employee->select(age > 50)->notEmpty()
is not supported by OCL.g4 either
'->select'
seems really dubious, as well as the string literals here. https://github.com/antlr/grammars-v4/blob/222722b82514b0fcbd300e4991851621c6be1c86/ocl/OCL.g4#L202-L294. In all other languages I've seen, the operator is separate from the keyword or ID. In Section 11.3 "Operations and Well-formedness Rules", there is no '->size()' but 'size()' function. Generally speaking, one should just have a syntax for function call, and dispense with parsing special-cased functions like size()
. This grammar looks very wrong.
I ain't a master of OCL or Antlr. But I guess it's written in this way to do better semantics check, so that these functions don't accept wrong parameters. After all, the functions in OCL are finite.