Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 06:36 Go to next message
Didier Garcin is currently offline Didier Garcin
Messages: 30
Registered: April 2013
Member
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]

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 17:25 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 700
Registered: July 2009
Senior Member
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 08:44 Go to previous messageGo to next message
Didier Garcin is currently offline Didier Garcin
Messages: 30
Registered: April 2013
Member
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 Rolling Eyes . 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 09:10]

Report message to a moderator

Re: [EVL 1.1] : lexical analysis and constraint scope [message #1114321 is a reply to message #1114256] Sun, 22 September 2013 10:58 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 700
Registered: July 2009
Senior Member
Hi Didier,

\ is an escape character in EOL (similarly to Java). To return [\*], your return statement should look like the following

return '[\\*]';

Regarding -*, I'm afraid this is a bug in the editor. Please file a bug report and I'll have a look at this shortly.

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=epsilon

Cheers,
Dimitris
Re: [EVL 1.1] : lexical analysis and constraint scope [message #1114492 is a reply to message #1114321] Sun, 22 September 2013 16:43 Go to previous message
Didier Garcin is currently offline Didier Garcin
Messages: 30
Registered: April 2013
Member
Ho, Yes ! It seems I am not very Java aware (If assuming it's a Java convention).

Thank you so much, Dimitris for your time spent on Sunday.

Best regards,
Didier.
Previous Topic:[Solved][EVL 1.1 editor ] : Conflict between ParameterDirectionKind#return and return keyword
Next Topic:[SOLVED][EUGENIA] generate EMFText model
Goto Forum:
  


Current Time: Fri Apr 18 19:28:46 EDT 2014

Powered by FUDForum. Page generated in 0.04100 seconds