lutaml / lutaml-uml

UML module for LutaML
2 stars 2 forks source link

UML syntax: Value specification #16

Open ronaldtse opened 4 years ago

ronaldtse commented 4 years ago

Value specification

Value specification-semantics

Screen Shot 2020-08-05 at 12 47 56 AM Screen Shot 2020-08-05 at 12 48 02 AM

Proposal:

instance :Expression {
  symbol="+"
  operand op1
  operand op2
}

instance op1:LiteralInteger {
  value = 1
}

instance op2:LiteralInteger {
  value = 1
}

// Or explicit association
:Expression <>-> |operand| op1:LiteralInteger
:Expression <>-> |operand| op2:LiteralInteger
w00lf commented 4 years ago

I think we should stick with object association declaration, so the first version looks better, but because we already have short hand notation for fields I think we should introduce keyword for values, something like this:

instance :Expression {
  value symbol="+"
  operand op1
  operand op2
}

instance op1:LiteralInteger {
  value value = 1
}

instance op2:LiteralInteger {
  value value = 1
}

value value = 1 looks kind of clumsy here I guess but it will be easier to implement and I guess we don't always have value = 1 as values.

ronaldtse commented 4 years ago

@w00lf in this case do we want to accept both "explicit" vs "implicit" syntax?

i.e. these two blocks are equivalent:

instance :Expression {
  myvalue=1
}

// is same as
instance :Expression {
  value myvalue=1
}

We can distinguish the case of value because value = 1 is of the pattern {attribute name} {equal sign} {attribute value}.

w00lf commented 4 years ago

@w00lf in this case do we want to accept both "explicit" vs "implicit" syntax?

i.e. these two blocks are equivalent:

instance :Expression {
  myvalue=1
}

// is same as
instance :Expression {
  value myvalue=1
}

We can distinguish the case of value because value = 1 is of the pattern {attribute name} {equal sign} {attribute value}.

in that case, we can just use the implicit syntax as you described above.

ronaldtse commented 4 years ago

in that case, we can just use the implicit syntax as you described above.

OK, so we now have established the syntax pattern of an attribute with value:

class {Class name, if any} {as ref name, optional} {
  {attribute name} = {attribute value}
  {attribute name}:{attribute class} = {attribute value}
}

instance :{Class name, if any} {as ref name, optional} {
  {attribute name} = {attribute value}
  {attribute name}:{attribute class} = {attribute value}
}