[Solved][EVL 1.1] : lexical analysis and constraint scope [message #1112900] |
Fri, 20 September 2013 06:36  |
Eclipse User |
|
|
|
Hi,
I encounter two problems while developing checking of well spelled identifiers.
I wish to check thanks to an EVL constraint, UML names of packages, classes, datatypes, primitive types, interfaces, attributes and operations.
So I declare the following.
operations.evl :
operation String isId() : Boolean
{
return self.matches('^[A-z]([_]?[0-9A-z])*$');
}
isId() succeeds if the string begins by a letter followed by letters or digits or underscores but not consecutive underscores.
So _myid, my__id, are rejected.
But, in practice, this is not the case. It seems there is a problem around the underscore character.
Which norm of regular expression does 'matches' function use ?
Finally ... I found how to solve this pb. See : self.matches('^[A-Za-z](_{0,1}[0-9A-Za-z])*$');
Nevertheless, what is following is still unsolved -->
12-packageableElements.evl :
context PackageableElement
{
constraint well_spelled_identifier
{
guard : not self.isKindOf(Association)
check : self.name.isDefined() and self.name.isId()
message
{
var id : String;
if (self.name.isDefined() and self.name <> '')
id = self.name;
else
id = self.id;
return 'Err #12.001 : ' + id + ' : ' + 'This name is not a valid identifier for the target language.';
}
}
}
This constraint says provided a packageable element is not an association, checks its name to be an identifier.
In practice, this constraint doesn't seem checking operations and attributes. In the other hand, it checks UML entities involved in cardinality of associations. It is not what I want to get.
What is wrong ?
Thanks your answers.
PS :
I'm joining a minimal example.
- 12-packageElements.evl contains the constraint in question, well_spelled_identifier.
- operations.evl contains (among others, not used here) isId() : Boolean.
- minimal.uml, an UML model containing :
the packages named _YouMissToRejectMyName_see_the_underscore_at_the_beginning, YouMiss__ToRejectMyName_see_the_consecutive_underscores whom names should be rejected.
An association between Class1 and Class2 whom cardinalities are abusively checked. Strange... Should not be checked by the constraint, well_spelled_identifier (12-packageableElements.evl) at all.
And Class3 whom the attribute's and operation's names should be checked and rejected, but not checked at all.
[Updated on: Sun, 22 September 2013 16:43] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03823 seconds