Home » Modeling » Epsilon » [Solved][EVL 1.1] : lexical analysis and constraint scope(regular expression and context problems)
[Solved][EVL 1.1] : lexical analysis and constraint scope [message #1112900] |
Fri, 20 September 2013 10:36 |
|
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 20:43] Report message to a moderator
|
|
|
Re: [EVL 1.1] : lexical analysis and constraint scope [message #1113860 is a reply to message #1112900] |
Sat, 21 September 2013 21:25 |
|
Hi Didier,
The following code indicates that the Operation and Property (attributes) do not inherit from PackageableElement in the UML metamodel. As such, their instances should not be checked by your constraint.
pre {
Property.all.first().isKindOf(Association).println(); // prints false
Operation.all.first().isKindOf(Association).println(); // prints false
}
Regarding the regular expression, EOL delegates pattern matching to Java. Could you please check whether your pattern works well in Java and let me know if there are any discrepancies?
Cheers,
Dimitris
|
|
|
Re: [EVL 1.1] : lexical analysis and constraint scope [message #1114256 is a reply to message #1113860] |
Sun, 22 September 2013 12:44 |
|
Hi Dimitris,
you are right, obviously.
Quote:works well in Java and let me know if there are any discrepancies?
It's a mistake of my own . To do [A-z] includes underscore (seen in the ASCII table). All is fine with '^[A-Za-z]([_]?[0-9A-Za-z])*$'.
So no discrepancy to worry. Definitively solved.
In the same perimeter (string literals), I've remarked something unsual with the syntax-sensible EVL editor :
- '[\*]', the editor triggers an error with this string inserted.
example :
operation const() : String
{
return '[\*]';
}
- and the following string sequence, -* in a string literal makes the rest of the text in green as if it was comment.
[Updated on: Sun, 22 September 2013 13:10] Report message to a moderator
|
|
| | |
Goto Forum:
Current Time: Thu Apr 25 10:05:04 GMT 2024
Powered by FUDForum. Page generated in 0.03051 seconds
|